From 117001b8986d46040da5c7b07330b5fb99fc7f70 Mon Sep 17 00:00:00 2001 From: Mitya Selivanov <0x7fffff@guattari.ru> Date: Sun, 14 Aug 2022 04:50:43 +0400 Subject: thread, atomic --- source/test/unittests/thread.test.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 source/test/unittests/thread.test.c (limited to 'source/test/unittests/thread.test.c') diff --git a/source/test/unittests/thread.test.c b/source/test/unittests/thread.test.c new file mode 100644 index 0000000..fed564b --- /dev/null +++ b/source/test/unittests/thread.test.c @@ -0,0 +1,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); +} -- cgit v1.2.3