Switch to using b32
This commit is contained in:
@@ -1,11 +1,10 @@
|
||||
#include "test_str8.h"
|
||||
#include "wapp.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#define ARRLEN(ARR) (sizeof(ARR) / sizeof(ARR[0]))
|
||||
|
||||
TestFuncResult test_str8_lit(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
result = s1.capacity == 22 && s1.capacity != s1.size;
|
||||
@@ -32,7 +31,7 @@ TestFuncResult test_str8_lit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_lit_ro(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = s1.capacity == 11 && s1.capacity == s1.size;
|
||||
@@ -59,7 +58,7 @@ TestFuncResult test_str8_lit_ro(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_buf(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 s1 = wapp_str8_buf(1024);
|
||||
result = s1.capacity == 1024 && s1.size == 0;
|
||||
@@ -77,7 +76,7 @@ TestFuncResult test_str8_buf(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_buf(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -105,7 +104,7 @@ TestFuncResult test_str8_alloc_buf(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_cstr(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -126,7 +125,7 @@ TestFuncResult test_str8_alloc_cstr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_str8(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -146,7 +145,7 @@ TestFuncResult test_str8_alloc_str8(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_substr(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator allocator = wapp_mem_arena_allocator_init(KB(100));
|
||||
if (wapp_mem_allocator_invalid(&allocator)) {
|
||||
return wapp_tester_result(false);
|
||||
@@ -166,7 +165,7 @@ TestFuncResult test_str8_alloc_substr(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("Hello world");
|
||||
result = wapp_str8_get(&s1, 4) == 'o';
|
||||
@@ -194,12 +193,12 @@ TestFuncResult test_str8_get_index_within_bounds(void) {
|
||||
|
||||
TestFuncResult test_str8_get_index_out_of_bounds(void) {
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
bool result = wapp_str8_get(&s1, 20) == '\0';
|
||||
b32 result = wapp_str8_get(&s1, 20) == '\0';
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_set(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 s1 = wapp_str8_lit("Hello world");
|
||||
wapp_str8_set(&s1, 4, 'f');
|
||||
@@ -233,7 +232,7 @@ TestFuncResult test_str8_set(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_push_back(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 expected = wapp_str8_lit("Abdelrahman");
|
||||
Str8 buf = wapp_str8_buf(64);
|
||||
@@ -255,7 +254,7 @@ TestFuncResult test_str8_push_back(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_equal(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8RO s1 = wapp_str8_lit_ro("hello");
|
||||
Str8RO s2 = wapp_str8_lit_ro("hell");
|
||||
@@ -270,7 +269,7 @@ TestFuncResult test_str8_equal(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_slice(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8 s = wapp_str8_lit("Different strokes for different folks");
|
||||
|
||||
Str8RO sub1 = wapp_str8_slice(&s, 3, 9);
|
||||
@@ -289,7 +288,7 @@ TestFuncResult test_str8_slice(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_alloc_concat(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
@@ -312,7 +311,7 @@ TestFuncResult test_str8_alloc_concat(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_concat_capped(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 str = wapp_str8_lit("Hello world");
|
||||
Str8 suffix1 = wapp_str8_lit(" from me.");
|
||||
@@ -330,7 +329,7 @@ TestFuncResult test_str8_concat_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
const char *src1 = "Hello world";
|
||||
@@ -348,7 +347,7 @@ TestFuncResult test_str8_copy_cstr_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(32);
|
||||
Str8RO src1 = wapp_str8_lit_ro("Hello world");
|
||||
@@ -365,7 +364,7 @@ TestFuncResult test_str8_copy_str8_capped(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_format(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 buf = wapp_str8_buf(128);
|
||||
Str8 expected = wapp_str8_lit("My name is Abdelrahman and I am 35 years old");
|
||||
@@ -378,7 +377,7 @@ TestFuncResult test_str8_format(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_find(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_find(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -394,7 +393,7 @@ TestFuncResult test_str8_find(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rfind(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
|
||||
|
||||
result = wapp_str8_rfind(&s, wapp_str8_lit_ro("d")) != -1;
|
||||
@@ -410,7 +409,7 @@ TestFuncResult test_str8_rfind(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -432,11 +431,11 @@ TestFuncResult test_str8_split(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
bool running1 = true;
|
||||
b32 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
bool running2 = true;
|
||||
b32 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;
|
||||
@@ -467,7 +466,7 @@ TestFuncResult test_str8_split(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_split_with_max(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -482,7 +481,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
bool running = true;
|
||||
b32 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -502,7 +501,7 @@ TestFuncResult test_str8_split_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -524,11 +523,11 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
|
||||
u64 index1 = 0;
|
||||
u64 count1 = ARRLEN(splits1);
|
||||
bool running1 = true;
|
||||
b32 running1 = true;
|
||||
|
||||
u64 index2 = 0;
|
||||
u64 count2 = ARRLEN(splits2);
|
||||
bool running2 = true;
|
||||
b32 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;
|
||||
@@ -559,7 +558,7 @@ TestFuncResult test_str8_rsplit(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -574,7 +573,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
|
||||
u64 index = 0;
|
||||
u64 count = ARRLEN(splits);
|
||||
bool running = true;
|
||||
b32 running = true;
|
||||
|
||||
result = list->node_count == count && wapp_str8_list_total_size(list) == str.size - 2;
|
||||
|
||||
@@ -594,7 +593,7 @@ TestFuncResult test_str8_rsplit_with_max(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_join(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
Allocator arena = wapp_mem_arena_allocator_init(KB(100));
|
||||
|
||||
Str8 str = wapp_str8_lit("hello world from me");
|
||||
@@ -614,7 +613,7 @@ TestFuncResult test_str8_join(void) {
|
||||
}
|
||||
|
||||
TestFuncResult test_str8_from_bytes(void) {
|
||||
bool result;
|
||||
b32 result;
|
||||
|
||||
Str8 str = wapp_str8_buf(1024);
|
||||
Str8 expected = wapp_str8_lit_ro("WAPP");
|
||||
|
Reference in New Issue
Block a user