summaryrefslogtreecommitdiff
path: root/source/tests
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-09-12 03:18:06 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-09-12 03:18:06 +0200
commitf0f23e874dd19a4fa3e41c8b489aa1f3fbd792c0 (patch)
treefdbd7af3fb7fe28959e5b983d10da3ca66078567 /source/tests
parentd16209180486738187487737832ba5675d5935ce (diff)
downloadkit-f0f23e874dd19a4fa3e41c8b489aa1f3fbd792c0.zip
Refactor; CAS atomics
Diffstat (limited to 'source/tests')
-rw-r--r--source/tests/atomic.test.c2
-rw-r--r--source/tests/bigint.test.c48
-rw-r--r--source/tests/condition_variable.test.c3
-rw-r--r--source/tests/file.test.c26
-rw-r--r--source/tests/mutex.test.c3
-rw-r--r--source/tests/thread.test.c2
6 files changed, 41 insertions, 43 deletions
diff --git a/source/tests/atomic.test.c b/source/tests/atomic.test.c
index efb5a61..061f5d6 100644
--- a/source/tests/atomic.test.c
+++ b/source/tests/atomic.test.c
@@ -1,5 +1,5 @@
#include "../kit/atomic.h"
-#include "../kit/thread.h"
+#include "../kit/threads.h"
#define KIT_TEST_FILE atomic
#include "../kit/kit_test.h"
diff --git a/source/tests/bigint.test.c b/source/tests/bigint.test.c
index 8efea16..94fd9ef 100644
--- a/source/tests/bigint.test.c
+++ b/source/tests/bigint.test.c
@@ -4,9 +4,9 @@
#define KIT_TEST_FILE bigint
#include "../kit/kit_test.h"
-#if __STDC_VERSION__ >= 199901L
-static_assert(sizeof(bigint_t) == 256, "KIT_BIGINT_SIZE check");
-#endif
+TEST("bigint size check") {
+ REQUIRE_EQ(sizeof(bigint_t), 256);
+}
TEST("bigint bin hex") {
REQUIRE(bi_equal(HEX("10"), BIN("10000")));
@@ -34,7 +34,7 @@ TEST("bigint hex sub") {
}
TEST("bigint base58") {
- REQUIRE(bi_equal(BASE58("31"), bi_uint32(58 * 2)));
+ REQUIRE(bi_equal(BASE58("31"), bi_u32(58 * 2)));
}
TEST("bigint base58 add") {
@@ -58,26 +58,26 @@ TEST("bigint base58 mul") {
}
TEST("bigint div") {
- REQUIRE(bi_equal(bi_div(bi_int32(-1), bi_int32(-1)).quotient,
- bi_int32(1)));
- REQUIRE(bi_equal(bi_div(bi_int32(-1), bi_int32(-1)).remainder,
- bi_int32(0)));
- REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(2)).quotient,
- bi_int32(-2)));
- REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(2)).remainder,
- bi_int32(1)));
- REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-2)).quotient,
- bi_int32(-1)));
- REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-2)).remainder,
- bi_int32(1)));
- REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(4)).quotient,
- bi_int32(-1)));
- REQUIRE(bi_equal(bi_div(bi_int32(-3), bi_int32(4)).remainder,
- bi_int32(3)));
- REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-4)).quotient,
- bi_int32(0)));
- REQUIRE(bi_equal(bi_div(bi_int32(3), bi_int32(-4)).remainder,
- bi_int32(3)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-1), bi_i32(-1)).quotient, bi_i32(1)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-1), bi_i32(-1)).remainder, bi_i32(0)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-3), bi_i32(2)).quotient, bi_i32(-2)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-3), bi_i32(2)).remainder, bi_i32(1)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(3), bi_i32(-2)).quotient, bi_i32(-1)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(3), bi_i32(-2)).remainder, bi_i32(1)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-3), bi_i32(4)).quotient, bi_i32(-1)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(-3), bi_i32(4)).remainder, bi_i32(3)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(3), bi_i32(-4)).quotient, bi_i32(0)));
+ REQUIRE(
+ bi_equal(bi_div(bi_i32(3), bi_i32(-4)).remainder, bi_i32(3)));
REQUIRE(
bi_equal(bi_div(HEX("100"), HEX("10")).quotient, HEX("10")));
diff --git a/source/tests/condition_variable.test.c b/source/tests/condition_variable.test.c
index fc2edd4..9deb9ae 100644
--- a/source/tests/condition_variable.test.c
+++ b/source/tests/condition_variable.test.c
@@ -1,5 +1,4 @@
-#include "../kit/condition_variable.h"
-#include "../kit/thread.h"
+#include "../kit/threads.h"
#define KIT_TEST_FILE condition_variable
#include "../kit/kit_test.h"
diff --git a/source/tests/file.test.c b/source/tests/file.test.c
index 0ca7b91..e6071a1 100644
--- a/source/tests/file.test.c
+++ b/source/tests/file.test.c
@@ -6,14 +6,14 @@
#include "../kit/kit_test.h"
TEST("file path cache") {
- string_t user = path_user(NULL);
- string_t cache = path_cache(NULL);
+ str_builder_t user = path_user(NULL);
+ str_builder_t cache = path_cache(NULL);
DA_RESIZE(cache, cache.size + 1);
cache.values[cache.size - 1] = '\0';
DA_RESIZE(cache, cache.size - 1);
- string_t expected =
+ str_builder_t expected =
#if defined(_WIN32) && !defined(__CYGWIN__)
path_join(WRAP_STR(user), SZ("AppData" PATH_DELIM "Local"),
NULL);
@@ -35,7 +35,7 @@ TEST("file path normalize one") {
str_t foo = SZ("foo/bar/../baz");
str_t foo_norm = SZ("foo" PATH_DELIM "baz");
- string_t bar = path_norm(foo, NULL);
+ str_builder_t bar = path_norm(foo, NULL);
REQUIRE(AR_EQUAL(foo_norm, bar));
@@ -46,7 +46,7 @@ TEST("file path normalize two") {
str_t foo = SZ("foo/bar/../../baz");
str_t foo_norm = SZ("baz");
- string_t bar = path_norm(foo, NULL);
+ str_builder_t bar = path_norm(foo, NULL);
REQUIRE(AR_EQUAL(foo_norm, bar));
@@ -57,7 +57,7 @@ TEST("file path normalize parent") {
str_t foo = SZ("../baz");
str_t foo_norm = SZ(".." PATH_DELIM "baz");
- string_t bar = path_norm(foo, NULL);
+ str_builder_t bar = path_norm(foo, NULL);
REQUIRE(AR_EQUAL(foo_norm, bar));
@@ -68,7 +68,7 @@ TEST("file path normalize double parent") {
str_t foo = SZ("foo/../../baz");
str_t foo_norm = SZ(".." PATH_DELIM "baz");
- string_t bar = path_norm(foo, NULL);
+ str_builder_t bar = path_norm(foo, NULL);
REQUIRE(AR_EQUAL(foo_norm, bar));
@@ -79,7 +79,7 @@ TEST("file path normalize windows delim") {
str_t foo = SZ("foo\\bar\\..\\baz");
str_t foo_norm = SZ("foo" PATH_DELIM "baz");
- string_t bar = path_norm(foo, NULL);
+ str_builder_t bar = path_norm(foo, NULL);
REQUIRE(AR_EQUAL(foo_norm, bar));
@@ -91,7 +91,7 @@ TEST("file path join no delim") {
str_t bar = SZ("bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
- string_t foobar = path_join(foo, bar, NULL);
+ str_builder_t foobar = path_join(foo, bar, NULL);
REQUIRE(AR_EQUAL(joined, foobar));
@@ -103,7 +103,7 @@ TEST("file path join delim left") {
str_t bar = SZ("bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
- string_t foobar = path_join(foo, bar, NULL);
+ str_builder_t foobar = path_join(foo, bar, NULL);
REQUIRE(AR_EQUAL(joined, foobar));
@@ -115,7 +115,7 @@ TEST("file path join delim right") {
str_t bar = SZ("/bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
- string_t foobar = path_join(foo, bar, NULL);
+ str_builder_t foobar = path_join(foo, bar, NULL);
REQUIRE(AR_EQUAL(joined, foobar));
@@ -127,7 +127,7 @@ TEST("file path join delim both") {
str_t bar = SZ("/bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
- string_t foobar = path_join(foo, bar, NULL);
+ str_builder_t foobar = path_join(foo, bar, NULL);
REQUIRE(AR_EQUAL(joined, foobar));
@@ -135,7 +135,7 @@ TEST("file path join delim both") {
}
TEST("file path user") {
- string_t user = path_user(NULL);
+ str_builder_t user = path_user(NULL);
REQUIRE(user.size > 0);
diff --git a/source/tests/mutex.test.c b/source/tests/mutex.test.c
index 8d52c69..578e48b 100644
--- a/source/tests/mutex.test.c
+++ b/source/tests/mutex.test.c
@@ -1,5 +1,4 @@
-#include "../kit/mutex.h"
-#include "../kit/thread.h"
+#include "../kit/threads.h"
#define KIT_TEST_FILE mutex
#include "../kit/kit_test.h"
diff --git a/source/tests/thread.test.c b/source/tests/thread.test.c
index 46c9597..8f849cd 100644
--- a/source/tests/thread.test.c
+++ b/source/tests/thread.test.c
@@ -1,4 +1,4 @@
-#include "../kit/thread.h"
+#include "../kit/threads.h"
#define KIT_TEST_FILE thread
#include "../kit/kit_test.h"