blob: fed564b2e269b2754d11c6b63feac649ad6d4baf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include "../../kit/thread.h"
#define KIT_TEST_FILE thread
#include "../../kit_test/test.h"
static void *test_thread_fn(void *data) {
ptrdiff_t *value = (ptrdiff_t *) data;
return (void *) (*value + 20);
}
TEST("run thread") {
pthread_t t;
ptrdiff_t value = 22;
pthread_create(&t, NULL, test_thread_fn, &value);
void *result;
pthread_join(t, &result);
REQUIRE((ptrdiff_t) result == 42);
}
|