Reformat tests

This commit is contained in:
2026-01-02 01:12:01 +00:00
parent 41cac2ef7f
commit 7be1b42107
17 changed files with 648 additions and 648 deletions

View File

@@ -6,26 +6,26 @@
TestFuncResult test_str8_lit(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
result = s1.capacity == 22 && s1.capacity != s1.size;
Str8 s1 = wapp_str8_lit("Hello world");
result = s1.capacity == 22 && s1.capacity != s1.size;
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
result = result && s2.capacity == 74 && s2.capacity != s2.size;
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
result = result && s2.capacity == 74 && s2.capacity != s2.size;
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
result = result && s3.capacity == 78 && s3.capacity != s3.size;
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
result = result && s3.capacity == 78 && s3.capacity != s3.size;
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
result = result && s4.capacity == 76 && s4.capacity != s4.size;
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
result = result && s4.capacity == 76 && s4.capacity != s4.size;
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
result = result && s5.capacity == 48 && s5.capacity != s5.size;
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
result = result && s5.capacity == 48 && s5.capacity != s5.size;
Str8 s6 = wapp_str8_lit("Do as you would be done by");
result = result && s6.capacity == 52 && s6.capacity != s6.size;
Str8 s6 = wapp_str8_lit("Do as you would be done by");
result = result && s6.capacity == 52 && s6.capacity != s6.size;
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
result = result && s7.capacity == 94 && s7.capacity != s7.size;
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
result = result && s7.capacity == 94 && s7.capacity != s7.size;
return wapp_tester_result(result);
}
@@ -33,26 +33,26 @@ TestFuncResult test_str8_lit(void) {
TestFuncResult test_str8_lit_ro(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
result = s1.capacity == 11 && s1.capacity == s1.size;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
result = s1.capacity == 11 && s1.capacity == s1.size;
Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks");
result = result && s2.capacity == 37 && s2.capacity == s2.size;
Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks");
result = result && s2.capacity == 37 && s2.capacity == s2.size;
Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour");
result = result && s3.capacity == 39 && s3.capacity == s3.size;
Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour");
result = result && s3.capacity == 39 && s3.capacity == s3.size;
Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view");
result = result && s4.capacity == 38 && s4.capacity == s4.size;
Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view");
result = result && s4.capacity == 38 && s4.capacity == s4.size;
Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do");
result = result && s5.capacity == 24 && s5.capacity == s5.size;
Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do");
result = result && s5.capacity == 24 && s5.capacity == s5.size;
Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by");
result = result && s6.capacity == 26 && s6.capacity == s6.size;
Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by");
result = result && s6.capacity == 26 && s6.capacity == s6.size;
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you");
result = result && s7.capacity == 47 && s7.capacity == s7.size;
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you");
result = result && s7.capacity == 47 && s7.capacity == s7.size;
return wapp_tester_result(result);
}
@@ -60,17 +60,17 @@ TestFuncResult test_str8_lit_ro(void) {
TestFuncResult test_str8_buf(void) {
b8 result;
Str8 s1 = wapp_str8_buf(1024);
result = s1.capacity == 1024 && s1.size == 0;
Str8 s1 = wapp_str8_buf(1024);
result = s1.capacity == 1024 && s1.size == 0;
Str8 s2 = wapp_str8_buf(2048);
result = result && s2.capacity == 2048 && s2.size == 0;
Str8 s2 = wapp_str8_buf(2048);
result = result && s2.capacity == 2048 && s2.size == 0;
Str8 s3 = wapp_str8_buf(4096);
result = result && s3.capacity == 4096 && s3.size == 0;
Str8 s3 = wapp_str8_buf(4096);
result = result && s3.capacity == 4096 && s3.size == 0;
Str8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0;
Str8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0;
return wapp_tester_result(result);
}
@@ -110,9 +110,9 @@ TestFuncResult test_str8_alloc_cstr(void) {
return wapp_tester_result(false);
}
char *str = "Abdelrahman";
u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
char *str = "Abdelrahman";
u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
if (!s) {
return wapp_tester_result(false);
}
@@ -131,8 +131,8 @@ TestFuncResult test_str8_alloc_str8(void) {
return wapp_tester_result(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
if (!s) {
return wapp_tester_result(false);
}
@@ -151,8 +151,8 @@ TestFuncResult test_str8_alloc_substr(void) {
return wapp_tester_result(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
if (!s) {
return wapp_tester_result(false);
}
@@ -167,66 +167,66 @@ TestFuncResult test_str8_alloc_substr(void) {
TestFuncResult test_str8_get_index_within_bounds(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
result = wapp_str8_get(&s1, 4) == 'o';
Str8RO s1 = wapp_str8_lit_ro("Hello world");
result = wapp_str8_get(&s1, 4) == 'o';
Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks");
result = result && wapp_str8_get(&s2, 0) == 'D';
Str8RO s2 = wapp_str8_lit_ro("Different strokes for different folks");
result = result && wapp_str8_get(&s2, 0) == 'D';
Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour");
result = result && wapp_str8_get(&s3, 13) == ' ';
Str8RO s3 = wapp_str8_lit_ro("Discretion is the better part of valour");
result = result && wapp_str8_get(&s3, 13) == ' ';
Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view");
result = result && wapp_str8_get(&s4, 20) == 'n';
Str8RO s4 = wapp_str8_lit_ro("Distance lends enchantment to the view");
result = result && wapp_str8_get(&s4, 20) == 'n';
Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do");
result = result && wapp_str8_get(&s5, 11) == ',';
Str8RO s5 = wapp_str8_lit_ro("Do as I say, not as I do");
result = result && wapp_str8_get(&s5, 11) == ',';
Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by");
result = result && wapp_str8_get(&s6, 25) == 'y';
Str8RO s6 = wapp_str8_lit_ro("Do as you would be done by");
result = result && wapp_str8_get(&s6, 25) == 'y';
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you");
result = result && wapp_str8_get(&s7, 16) == 's';
Str8RO s7 = wapp_str8_lit_ro("Do unto others as you would have them do to you");
result = result && wapp_str8_get(&s7, 16) == 's';
return wapp_tester_result(result);
}
TestFuncResult test_str8_get_index_out_of_bounds(void) {
Str8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0';
Str8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0';
return wapp_tester_result(result);
}
TestFuncResult test_str8_set(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
Str8 s1 = wapp_str8_lit("Hello world");
wapp_str8_set(&s1, 4, 'f');
result = wapp_str8_get(&s1, 4) == 'f';
result = wapp_str8_get(&s1, 4) == 'f';
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
wapp_str8_set(&s2, 0, 'A');
result = result && wapp_str8_get(&s2, 0) == 'A';
result = result && wapp_str8_get(&s2, 0) == 'A';
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
wapp_str8_set(&s3, 13, 'u');
result = result && wapp_str8_get(&s3, 13) == 'u';
result = result && wapp_str8_get(&s3, 13) == 'u';
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
wapp_str8_set(&s4, 20, 'R');
result = result && wapp_str8_get(&s4, 20) == 'R';
result = result && wapp_str8_get(&s4, 20) == 'R';
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
wapp_str8_set(&s5, 11, '.');
result = result && wapp_str8_get(&s5, 11) == '.';
result = result && wapp_str8_get(&s5, 11) == '.';
Str8 s6 = wapp_str8_lit("Do as you would be done by");
Str8 s6 = wapp_str8_lit("Do as you would be done by");
wapp_str8_set(&s6, 25, 'w');
result = result && wapp_str8_get(&s6, 25) == 'w';
result = result && wapp_str8_get(&s6, 25) == 'w';
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
wapp_str8_set(&s7, 16, 'i');
result = result && wapp_str8_get(&s7, 16) == 'i';
result = result && wapp_str8_get(&s7, 16) == 'i';
return wapp_tester_result(result);
}
@@ -234,8 +234,8 @@ TestFuncResult test_str8_set(void) {
TestFuncResult test_str8_push_back(void) {
b8 result;
Str8 expected = wapp_str8_lit("Abdelrahman");
Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_lit("Abdelrahman");
Str8 buf = wapp_str8_buf(64);
wapp_str8_push_back(&buf, 'A');
wapp_str8_push_back(&buf, 'b');
wapp_str8_push_back(&buf, 'd');
@@ -291,11 +291,11 @@ TestFuncResult test_str8_alloc_concat(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("Hello world");
Str8 suffix1 = wapp_str8_lit(" from me.");
Str8 suffix2 = wapp_str8_lit(" This is my code.");
Str8 concat1 = wapp_str8_lit("Hello world from me.");
Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code.");
Str8 str = wapp_str8_lit("Hello world");
Str8 suffix1 = wapp_str8_lit(" from me.");
Str8 suffix2 = wapp_str8_lit(" This is my code.");
Str8 concat1 = wapp_str8_lit("Hello world from me.");
Str8 concat2 = wapp_str8_lit("Hello world from me. This is my code.");
Str8 *output;
@@ -313,11 +313,11 @@ TestFuncResult test_str8_alloc_concat(void) {
TestFuncResult test_str8_concat_capped(void) {
b8 result;
Str8 str = wapp_str8_lit("Hello world");
Str8 suffix1 = wapp_str8_lit(" from me.");
Str8 suffix2 = wapp_str8_lit(" This is my code.");
Str8 concat1 = wapp_str8_lit("Hello world from me.");
Str8 concat2 = wapp_str8_lit("Hello world from me. T");
Str8 str = wapp_str8_lit("Hello world");
Str8 suffix1 = wapp_str8_lit(" from me.");
Str8 suffix2 = wapp_str8_lit(" This is my code.");
Str8 concat1 = wapp_str8_lit("Hello world from me.");
Str8 concat2 = wapp_str8_lit("Hello world from me. T");
wapp_str8_concat_capped(&str, &suffix1);
result = str.size == concat1.size && wapp_str8_equal(&str, &concat1);
@@ -331,11 +331,11 @@ TestFuncResult test_str8_concat_capped(void) {
TestFuncResult test_str8_copy_cstr_capped(void) {
b8 result;
Str8 buf = wapp_str8_buf(32);
const char *src1 = "Hello world";
const char *src2 = "Hello world from the Wizard Apprentice standard library";
Str8RO src1_cp = wapp_str8_lit_ro("Hello world");
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
Str8 buf = wapp_str8_buf(32);
const char *src1 = "Hello world";
const char *src2 = "Hello world from the Wizard Apprentice standard library";
Str8RO src1_cp = wapp_str8_lit_ro("Hello world");
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
wapp_str8_copy_cstr_capped(&buf, src1);
result = buf.size == src1_cp.size && wapp_str8_equal(&buf, &src1_cp);
@@ -349,10 +349,10 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
TestFuncResult test_str8_copy_str8_capped(void) {
b8 result;
Str8 buf = wapp_str8_buf(32);
Str8RO src1 = wapp_str8_lit_ro("Hello world");
Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library");
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
Str8 buf = wapp_str8_buf(32);
Str8RO src1 = wapp_str8_lit_ro("Hello world");
Str8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library");
Str8RO src2_cp = wapp_str8_lit_ro("Hello world from the Wizard Appr");
wapp_str8_copy_str8_capped(&buf, &src1);
result = buf.size == src1.size && wapp_str8_equal(&buf, &src1);
@@ -366,8 +366,8 @@ TestFuncResult test_str8_copy_str8_capped(void) {
TestFuncResult test_str8_format(void) {
b8 result;
Str8 buf = wapp_str8_buf(128);
Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old");
Str8 buf = wapp_str8_buf(128);
Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old");
wapp_str8_format(&buf, "My name is %s and I am %u years old", "Abdelrahman", 35);
@@ -412,11 +412,11 @@ TestFuncResult test_str8_split(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_split(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_split(&arena, &str, &delim2);
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_split(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_split(&arena, &str, &delim2);
Str8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
@@ -429,13 +429,13 @@ TestFuncResult test_str8_split(void) {
wapp_str8_slice(&str, 16, 19),
};
u64 index1 = 0;
u64 count1 = ARRLEN(splits1);
b8 running1 = true;
u64 index1 = 0;
u64 count1 = ARRLEN(splits1);
b8 running1 = true;
u64 index2 = 0;
u64 count2 = ARRLEN(splits2);
b8 running2 = true;
u64 index2 = 0;
u64 count2 = ARRLEN(splits2);
b8 running2 = true;
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
@@ -469,9 +469,9 @@ TestFuncResult test_str8_split_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim = wapp_str8_lit(" ");
Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2);
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim = wapp_str8_lit(" ");
Str8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
wapp_str8_slice(&str, 0, 5),
@@ -479,9 +479,9 @@ TestFuncResult test_str8_split_with_max(void) {
wapp_str8_slice(&str, 12, 19),
};
u64 index = 0;
u64 count = ARRLEN(splits);
b8 running = true;
u64 index = 0;
u64 count = ARRLEN(splits);
b8 running = true;
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
@@ -504,11 +504,11 @@ TestFuncResult test_str8_rsplit(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
@@ -521,13 +521,13 @@ TestFuncResult test_str8_rsplit(void) {
wapp_str8_slice(&str, 16, 19),
};
u64 index1 = 0;
u64 count1 = ARRLEN(splits1);
b8 running1 = true;
u64 index1 = 0;
u64 count1 = ARRLEN(splits1);
b8 running1 = true;
u64 index2 = 0;
u64 count2 = ARRLEN(splits2);
b8 running2 = true;
u64 index2 = 0;
u64 count2 = ARRLEN(splits2);
b8 running2 = true;
result = list1->node_count == count1 && wapp_str8_list_total_size(list1) == str.size - 3;
result = result && list2->node_count == count2 && wapp_str8_list_total_size(list2) == str.size - 4;
@@ -561,9 +561,9 @@ TestFuncResult test_str8_rsplit_with_max(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim = wapp_str8_lit(" ");
Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2);
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim = wapp_str8_lit(" ");
Str8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
wapp_str8_slice(&str, 0, 11),
@@ -571,9 +571,9 @@ TestFuncResult test_str8_rsplit_with_max(void) {
wapp_str8_slice(&str, 17, 19),
};
u64 index = 0;
u64 count = ARRLEN(splits);
b8 running = true;
u64 index = 0;
u64 count = ARRLEN(splits);
b8 running = true;
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
@@ -596,13 +596,13 @@ TestFuncResult test_str8_join(void) {
b8 result;
Allocator arena = wapp_mem_arena_allocator_init(KiB(100));
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8 *join1 = wapp_str8_join(&arena, list1, &delim1);
Str8 *join2 = wapp_str8_join(&arena, list2, &delim2);
Str8 str = wapp_str8_lit("hello world from me");
Str8 delim1 = wapp_str8_lit(" ");
Str8 delim2 = wapp_str8_lit("from");
Str8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
Str8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8 *join1 = wapp_str8_join(&arena, list1, &delim1);
Str8 *join2 = wapp_str8_join(&arena, list2, &delim2);
result = join1->size == str.size && wapp_str8_equal(join1, &str);
result = result && join2->size == str.size && wapp_str8_equal(join2, &str);
@@ -615,7 +615,7 @@ TestFuncResult test_str8_join(void) {
TestFuncResult test_str8_from_bytes(void) {
b8 result;
Str8 str = wapp_str8_buf(1024);
Str8 str = wapp_str8_buf(1024);
U8Array bytes = wapp_array(u8, U8Array, 'W', 'A', 'P', 'P');
wapp_str8_from_bytes(&str, &bytes);