Start str8 renaming

This commit is contained in:
2026-06-26 16:02:12 +01:00
parent cd797683d2
commit acbfc9088c
34 changed files with 729 additions and 729 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ BEGIN_C_LINKAGE
#define _calc_array_count(TYPE, ...) wpMiscUtilsVaArgsCount(TYPE, __VA_ARGS__)
#define _calc_array_capacity(TYPE, ...) wpMiscUtilsU64RoundUpPow2(_calc_array_count(TYPE, __VA_ARGS__) * 2)
typedef struct Str8 Str8;
typedef struct WpStr8 WpStr8;
// NOTE (Abdelrahman): Typedefs to distinguish arrays from regular pointers
typedef void *GenericArray;
@@ -39,7 +39,7 @@ typedef f64 *F64Array;
typedef f128 *F128Array;
typedef uptr *UptrArray;
typedef iptr *IptrArray;
typedef Str8 *Str8Array;
typedef WpStr8 *WpStr8Array;
typedef enum {
ARRAY_INIT_NONE = 0,
+2 -2
View File
@@ -55,7 +55,7 @@ typedef GenericList F64List;
typedef GenericList F128List;
typedef GenericList UptrList;
typedef GenericList IptrList;
typedef GenericList Str8List;
typedef GenericList WpStr8List;
// NOTE (Abdelrahman): GenericNode typedefs for readability
typedef GenericNode VoidPtrNode;
@@ -76,7 +76,7 @@ typedef GenericNode F64Node;
typedef GenericNode F128Node;
typedef GenericNode UptrNode;
typedef GenericNode IptrNode;
typedef GenericNode Str8Node;
typedef GenericNode WpStr8Node;
#ifdef WP_PLATFORM_CPP
#define wapp_dbl_list(TYPE) \
+1 -1
View File
@@ -38,7 +38,7 @@ typedef GenericQueue F64Queue;
typedef GenericQueue F128Queue;
typedef GenericQueue UptrQueue;
typedef GenericQueue IptrQueue;
typedef GenericQueue Str8Queue;
typedef GenericQueue WpStr8Queue;
#ifdef WP_PLATFORM_CPP
#define wapp_queue(TYPE, CAPACITY) ([&]() { \
+57 -57
View File
@@ -11,17 +11,17 @@
#include <stdio.h>
#include <string.h>
#define STR8_BUF_ALLOC_SIZE(CAPACITY) (sizeof(Str8) + sizeof(c8) * CAPACITY)
#define STR8_BUF_ALLOC_SIZE(CAPACITY) (sizeof(WpStr8) + sizeof(c8) * CAPACITY)
Str8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity) {
WpStr8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity) {
wpDebugAssert(allocator != NULL, "`allocator` should not be NULL");
Str8 *str = wapp_mem_allocator_alloc(allocator, STR8_BUF_ALLOC_SIZE(capacity));
WpStr8 *str = wapp_mem_allocator_alloc(allocator, STR8_BUF_ALLOC_SIZE(capacity));
if (!str) {
goto RETURN_STR8;
}
str->buf = (u8 *)str + sizeof(Str8);
str->buf = (u8 *)str + sizeof(WpStr8);
str->size = 0;
str->capacity = capacity;
@@ -29,8 +29,8 @@ RETURN_STR8:
return str;
}
Str8 *wapp_str8_alloc_and_fill_buf(const Allocator *allocator, u64 capacity) {
Str8 *out = wapp_str8_alloc_buf(allocator, capacity);
WpStr8 *wapp_str8_alloc_and_fill_buf(const Allocator *allocator, u64 capacity) {
WpStr8 *out = wapp_str8_alloc_buf(allocator, capacity);
if (out) {
memset(out->buf, 0, capacity);
out->size = capacity;
@@ -38,11 +38,11 @@ Str8 *wapp_str8_alloc_and_fill_buf(const Allocator *allocator, u64 capacity) {
return out;
}
Str8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str) {
WpStr8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str) {
wpDebugAssert(allocator != NULL && str != NULL, "`allocator` and `str` should not be NULL");
u64 length = strlen(str);
Str8 *output = wapp_str8_alloc_buf(allocator, length * 2);
WpStr8 *output = wapp_str8_alloc_buf(allocator, length * 2);
if (!output) {
goto RETURN_ALLOC_CSTR;
}
@@ -54,10 +54,10 @@ RETURN_ALLOC_CSTR:
return output;
}
Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str) {
WpStr8 *wapp_str8_alloc_str8(const Allocator *allocator, WpStr8RO *str) {
wpDebugAssert(allocator != NULL && str != NULL, "`allocator` and `str` should not be NULL");
Str8 *output = wapp_str8_alloc_buf(allocator, str->capacity);
WpStr8 *output = wapp_str8_alloc_buf(allocator, str->capacity);
if (!output) {
goto RETURN_ALLOC_STR8;
}
@@ -69,10 +69,10 @@ RETURN_ALLOC_STR8:
return output;
}
Str8 *wapp_str8_alloc_substr(const Allocator *allocator, Str8RO *str, u64 start, u64 end) {
WpStr8 *wapp_str8_alloc_substr(const Allocator *allocator, WpStr8RO *str, u64 start, u64 end) {
wpDebugAssert(allocator != NULL && str != NULL, "`allocator` and `str` should not be NULL");
Str8 *output = NULL;
WpStr8 *output = NULL;
if (start >= str->size || start >= end) {
goto RETURN_ALLOC_SUBSTR;
@@ -94,12 +94,12 @@ RETURN_ALLOC_SUBSTR:
return output;
}
void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str) {
void wapp_str8_dealloc_buf(const Allocator *allocator, WpStr8 **str) {
wpDebugAssert(allocator != NULL && str != NULL && (*str) != NULL, "Either `allocator` is NULL or `str` is an invalid double pointer");
wapp_mem_allocator_free(allocator, (void **)str, STR8_BUF_ALLOC_SIZE((*str)->capacity));
}
c8 wapp_str8_get(const Str8 *str, u64 index) {
c8 wapp_str8_get(const WpStr8 *str, u64 index) {
if (index >= str->size) {
return '\0';
}
@@ -107,7 +107,7 @@ c8 wapp_str8_get(const Str8 *str, u64 index) {
return str->buf[index];
}
void wapp_str8_set(Str8 *str, u64 index, c8 c) {
void wapp_str8_set(WpStr8 *str, u64 index, c8 c) {
if (index >= str->size) {
return;
}
@@ -115,7 +115,7 @@ void wapp_str8_set(Str8 *str, u64 index, c8 c) {
str->buf[index] = c;
}
void wapp_str8_push_back(Str8 *str, c8 c) {
void wapp_str8_push_back(WpStr8 *str, c8 c) {
if (!(str->size < str->capacity)) {
return;
}
@@ -124,7 +124,7 @@ void wapp_str8_push_back(Str8 *str, c8 c) {
wapp_str8_set(str, index, c);
}
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
b8 wapp_str8_equal(WpStr8RO *s1, WpStr8RO *s2) {
if (s1->size != s2->size) {
return false;
}
@@ -132,7 +132,7 @@ b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
return wapp_str8_equal_to_count(s1, s2, s1->size);
}
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
b8 wapp_str8_equal_to_count(WpStr8RO* s1, WpStr8RO* s2, u64 count) {
if (!s1 || !s2) {
return false;
}
@@ -140,7 +140,7 @@ b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
return memcmp(s1->buf, s2->buf, count) == 0;
}
Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end) {
WpStr8 wapp_str8_slice(WpStr8RO *str, u64 start, u64 end) {
if (start >= str->size || start >= end) {
start = str->size;
end = str->size;
@@ -150,17 +150,17 @@ Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end) {
end = str->size;
}
return (Str8RO){
return (WpStr8RO){
.capacity = end - start,
.size = end - start,
.buf = str->buf + start,
};
}
Str8 *wapp_str8_alloc_concat(const Allocator *allocator, Str8 *dst, Str8RO *src) {
WpStr8 *wapp_str8_alloc_concat(const Allocator *allocator, WpStr8 *dst, WpStr8RO *src) {
wpDebugAssert(allocator != NULL && dst != NULL && src != NULL, "`allocator`, `dst` and `src` should not be NULL");
Str8 *output = NULL;
WpStr8 *output = NULL;
u64 remaining = dst->capacity - dst->size;
if (src->size <= remaining) {
output = dst;
@@ -183,7 +183,7 @@ RETURN_STR8_CONCAT:
return output;
}
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) {
void wapp_str8_concat_capped(WpStr8 *dst, WpStr8RO *src) {
wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL");
u64 remaining = dst->capacity - dst->size;
@@ -193,7 +193,7 @@ void wapp_str8_concat_capped(Str8 *dst, Str8RO *src) {
dst->size += to_copy;
}
void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src) {
void wapp_str8_copy_cstr_capped(WpStr8 *dst, const char *src) {
wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL");
u64 length = strlen(src);
@@ -204,7 +204,7 @@ void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src) {
dst->size = to_copy;
}
void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src) {
void wapp_str8_copy_str8_capped(WpStr8 *dst, WpStr8RO *src) {
wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL");
u64 to_copy = src->size <= dst->capacity ? src->size : dst->capacity;
@@ -214,7 +214,7 @@ void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src) {
dst->size = to_copy;
}
void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity) {
void wapp_str8_copy_to_cstr(char *dst, WpStr8RO *src, u64 dst_capacity) {
wpDebugAssert(dst != NULL && src != NULL, "`dst` and `src` should not be NULL");
u64 to_copy = src->size < dst_capacity ? src->size : dst_capacity - 1;
@@ -223,7 +223,7 @@ void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity) {
memcpy(dst, src->buf, to_copy);
}
void wapp_str8_format(Str8 *dst, const char *format, ...) {
void wapp_str8_format(WpStr8 *dst, const char *format, ...) {
wpDebugAssert(dst != NULL && format != NULL, "`dst` and `format` should not be NULL");
va_list args1;
@@ -241,7 +241,7 @@ void wapp_str8_format(Str8 *dst, const char *format, ...) {
va_end(args2);
}
void wapp_str8_to_lower(Str8 *dst, Str8RO *src) {
void wapp_str8_to_lower(WpStr8 *dst, WpStr8RO *src) {
wpDebugAssert(src != NULL && dst != NULL, "`dst` and `src` should not be NULL");
wpDebugAssert(dst->capacity >= src->capacity, "`dst` does not have enough capacity");
@@ -258,7 +258,7 @@ void wapp_str8_to_lower(Str8 *dst, Str8RO *src) {
}
}
void wapp_str8_to_upper(Str8 *dst, Str8RO *src) {
void wapp_str8_to_upper(WpStr8 *dst, WpStr8RO *src) {
wpDebugAssert(src != NULL && dst != NULL, "`dst` and `src` should not be NULL");
wpDebugAssert(dst->capacity >= src->capacity, "`dst` does not have enough capacity");
@@ -275,7 +275,7 @@ void wapp_str8_to_upper(Str8 *dst, Str8RO *src) {
}
}
void wapp_str8_from_bytes(Str8 *dst, const U8Array src) {
void wapp_str8_from_bytes(WpStr8 *dst, const U8Array src) {
wpDebugAssert(src != NULL && dst != NULL, "`dst` and `src` should not be NULL");
u64 size = wapp_array_count(src) * wapp_array_item_size(src);
@@ -286,7 +286,7 @@ void wapp_str8_from_bytes(Str8 *dst, const U8Array src) {
memcpy(dst->buf, src, size);
}
i64 wapp_str8_find(Str8RO *str, Str8RO substr) {
i64 wapp_str8_find(WpStr8RO *str, WpStr8RO substr) {
if (!str || substr.size > str->size) {
return -1;
}
@@ -308,7 +308,7 @@ i64 wapp_str8_find(Str8RO *str, Str8RO substr) {
return -1;
}
i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
i64 wapp_str8_rfind(WpStr8RO *str, WpStr8RO substr) {
if (!str || substr.size > str->size) {
return -1;
}
@@ -330,15 +330,15 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
return -1;
}
Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
WpStr8List *wapp_str8_split_with_max(const Allocator *allocator, WpStr8RO *str, WpStr8RO *delimiter, i64 max_splits) {
wpDebugAssert(allocator != NULL && str != NULL && delimiter != NULL, "`allocator`, `str` and `delimiter` should not be NULL");
Str8List *output = wapp_dbl_list_alloc(Str8, allocator);
WpStr8List *output = wapp_dbl_list_alloc(WpStr8, allocator);
if (delimiter->size > str->size) {
Str8 *full = wapp_str8_alloc_str8(allocator, str);
WpStr8 *full = wapp_str8_alloc_str8(allocator, str);
if (full) {
wapp_dbl_list_push_back_alloc(Str8, allocator, output, full);
wapp_dbl_list_push_back_alloc(WpStr8, allocator, output, full);
}
goto RETURN_STR8_SPLIT;
@@ -347,8 +347,8 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
i64 start = 0;
i64 end = 0;
i64 splits = 0;
Str8 *rest = wapp_str8_alloc_str8(allocator, str);
Str8 *before_str;
WpStr8 *rest = wapp_str8_alloc_str8(allocator, str);
WpStr8 *before_str;
while ((end = wapp_str8_find(rest, *delimiter)) != -1) {
if (max_splits > 0 && splits >= max_splits) {
@@ -357,10 +357,10 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
before_str = wapp_str8_alloc_substr(allocator, str, start, start + end);
if (before_str) {
wapp_dbl_list_push_back_alloc(Str8, allocator, output, before_str);
wapp_dbl_list_push_back_alloc(WpStr8, allocator, output, before_str);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(WpStr8));
rest = wapp_str8_alloc_substr(allocator, str, start + end + delimiter->size, str->size);
start += end + delimiter->size;
@@ -370,22 +370,22 @@ Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8
// Ensure the last part of the string after the delimiter is added to the list
rest = wapp_str8_alloc_substr(allocator, str, start, str->size);
if (rest) {
wapp_dbl_list_push_back_alloc(Str8, allocator, output, rest);
wapp_dbl_list_push_back_alloc(WpStr8, allocator, output, rest);
}
RETURN_STR8_SPLIT:
return output;
}
Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits) {
WpStr8List *wapp_str8_rsplit_with_max(const Allocator *allocator, WpStr8RO *str, WpStr8RO *delimiter, i64 max_splits) {
wpDebugAssert(allocator != NULL && str != NULL && delimiter != NULL, "`allocator`, `str` and `delimiter` should not be NULL");
Str8List *output = wapp_dbl_list_alloc(Str8, allocator);
WpStr8List *output = wapp_dbl_list_alloc(WpStr8, allocator);
if (delimiter->size > str->size) {
Str8 *full = wapp_str8_alloc_str8(allocator, str);
WpStr8 *full = wapp_str8_alloc_str8(allocator, str);
if (full) {
wapp_dbl_list_push_back_alloc(Str8, allocator, output, full);
wapp_dbl_list_push_back_alloc(WpStr8, allocator, output, full);
}
goto RETURN_STR8_SPLIT;
@@ -393,8 +393,8 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
i64 end = 0;
i64 splits = 0;
Str8 *rest = wapp_str8_alloc_str8(allocator, str);
Str8 *after_str;
WpStr8 *rest = wapp_str8_alloc_str8(allocator, str);
WpStr8 *after_str;
while ((end = wapp_str8_rfind(rest, *delimiter)) != -1) {
if (max_splits > 0 && splits >= max_splits) {
@@ -403,10 +403,10 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
after_str = wapp_str8_alloc_substr(allocator, rest, end + delimiter->size, str->size);
if (after_str) {
wapp_dbl_list_push_front_alloc(Str8, allocator, output, after_str);
wapp_dbl_list_push_front_alloc(WpStr8, allocator, output, after_str);
}
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(Str8));
wapp_mem_allocator_free(allocator, (void **)&rest, sizeof(WpStr8));
rest = wapp_str8_alloc_substr(allocator, rest, 0, end);
++splits;
@@ -414,26 +414,26 @@ Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str
rest = wapp_str8_alloc_substr(allocator, str, 0, rest->size);
if (rest) {
wapp_dbl_list_push_front_alloc(Str8, allocator, output, rest);
wapp_dbl_list_push_front_alloc(WpStr8, allocator, output, rest);
}
RETURN_STR8_SPLIT:
return output;
}
Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *delimiter) {
WpStr8 *wapp_str8_join(const Allocator *allocator, const WpStr8List *list, WpStr8RO *delimiter) {
wpDebugAssert(allocator != NULL && list != NULL && delimiter != NULL, "`allocator`, `list` and `delimiter` should not be NULL");
u64 capacity = wapp_str8_list_total_size(list) + (delimiter->size * (list->node_count - 1));
Str8 *output = wapp_str8_alloc_buf(allocator, capacity * 2);
WpStr8 *output = wapp_str8_alloc_buf(allocator, capacity * 2);
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
Str8 *node;
WpStr8 *node;
u64 node_index = 0;
b8 running = node_index < list->node_count;
while (running) {
node = wapp_dbl_list_get(Str8, list, node_index);
node = wapp_dbl_list_get(WpStr8, list, node_index);
if (!node) {
break;
}
@@ -454,19 +454,19 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
return output;
}
u64 wapp_str8_list_total_size(const Str8List *list) {
u64 wapp_str8_list_total_size(const WpStr8List *list) {
if (!list) {
return 0;
}
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
Str8 *node;
WpStr8 *node;
u64 node_index = 0;
u64 output = 0;
b8 running = node_index < list->node_count;
while (running) {
node = wapp_dbl_list_get(Str8, list, node_index);
node = wapp_dbl_list_get(WpStr8, list, node_index);
if (!node) {
break;
}
+45 -45
View File
@@ -15,23 +15,23 @@
BEGIN_C_LINKAGE
#endif // !WP_PLATFORM_CPP
typedef struct Str8 Str8;
struct Str8 {
typedef struct WpStr8 WpStr8;
struct WpStr8 {
u64 capacity;
u64 size;
c8 *buf;
};
typedef const Str8 Str8RO;
typedef const WpStr8 WpStr8RO;
/**
* Utilities to be used with printf functions
*/
#define WAPP_STR8_SPEC "%.*s"
#define wapp_str8_varg(STRING) (int)((STRING).size), (STRING).buf
#define WP_STR8_SPEC "%.*s"
#define wpStr8Varg(STRING) (int)((STRING).size), (STRING).buf
/**
* Str8 stack buffers
* WpStr8 stack buffers
*/
#ifdef WP_PLATFORM_CPP
@@ -39,89 +39,89 @@ typedef const Str8 Str8RO;
#define wapp_str8_buf(CAPACITY) ([&](){ \
wp_persist c8 buf[CAPACITY] = {}; \
memset(buf, 0, CAPACITY); \
return Str8{CAPACITY, 0, buf}; \
return WpStr8{CAPACITY, 0, buf}; \
}())
// Uses a lambda to achieve the same behaviour achieved by the C macro
#define wapp_str8_lit(STRING) ([&]() { \
wp_persist c8 buf[sizeof(STRING) * 2] = {}; \
memcpy(buf, STRING, sizeof(STRING)); \
return Str8{(sizeof(STRING) - 1) * 2, sizeof(STRING) - 1, buf}; \
return WpStr8{(sizeof(STRING) - 1) * 2, sizeof(STRING) - 1, buf}; \
}())
#define wapp_str8_lit_ro(STRING) Str8RO{sizeof(STRING) - 1, sizeof(STRING) - 1, (c8 *)STRING}
#define wapp_str8_lit_ro(STRING) WpStr8RO{sizeof(STRING) - 1, sizeof(STRING) - 1, (c8 *)STRING}
#define wapp_str8_lit_ro_initialiser_list(STRING) {sizeof(STRING) - 1, sizeof(STRING) - 1, (c8 *)STRING}
#else
#define wapp_str8_buf(CAPACITY) ((Str8){.capacity = CAPACITY, .size = 0, .buf = (c8[CAPACITY]){0}})
#define wapp_str8_buf(CAPACITY) ((WpStr8){.capacity = CAPACITY, .size = 0, .buf = (c8[CAPACITY]){0}})
// Utilises the fact that memcpy returns pointer to dest buffer and that getting
// address of compound literals is valid in C to create a string on the stack
#define wapp_str8_lit(STRING) ((Str8){.capacity = (sizeof(STRING) - 1) * 2, \
#define wapp_str8_lit(STRING) ((WpStr8){.capacity = (sizeof(STRING) - 1) * 2, \
.size = sizeof(STRING) - 1, \
.buf = memcpy(&((c8 [sizeof(STRING) * 2]){0}), \
STRING, \
sizeof(STRING))})
#define wapp_str8_lit_ro(STRING) ((Str8RO){.capacity = sizeof(STRING) - 1, \
#define wapp_str8_lit_ro(STRING) ((WpStr8RO){.capacity = sizeof(STRING) - 1, \
.size = sizeof(STRING) - 1, \
.buf = (c8 *)STRING})
// To be used only when initialising a static storage variable in compilers that don't support
// initialisers with the syntax of wapp_str8_lit_ro (e.g. gcc). Should only be used when necessary
// and only be assigned to a Str8RO variable to avoid any attempt at modifying the string
// and only be assigned to a WpStr8RO variable to avoid any attempt at modifying the string
#define wapp_str8_lit_ro_initialiser_list(STRING) {.capacity = sizeof(STRING) - 1, \
.size = sizeof(STRING) - 1, \
.buf = (c8 *)STRING}
#endif // !WP_PLATFORM_CPP
/**
* Str8 allocated buffers
* WpStr8 allocated buffers
*/
Str8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity);
Str8 *wapp_str8_alloc_and_fill_buf(const Allocator *allocator, u64 capacity);
Str8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str);
Str8 *wapp_str8_alloc_str8(const Allocator *allocator, Str8RO *str);
Str8 *wapp_str8_alloc_substr(const Allocator *allocator, Str8RO *str, u64 start, u64 end);
Str8 *wapp_str8_alloc_concat(const Allocator *allocator, Str8 *dst, Str8RO *src);
WpStr8 *wapp_str8_alloc_buf(const Allocator *allocator, u64 capacity);
WpStr8 *wapp_str8_alloc_and_fill_buf(const Allocator *allocator, u64 capacity);
WpStr8 *wapp_str8_alloc_cstr(const Allocator *allocator, const char *str);
WpStr8 *wapp_str8_alloc_str8(const Allocator *allocator, WpStr8RO *str);
WpStr8 *wapp_str8_alloc_substr(const Allocator *allocator, WpStr8RO *str, u64 start, u64 end);
WpStr8 *wapp_str8_alloc_concat(const Allocator *allocator, WpStr8 *dst, WpStr8RO *src);
// Only needed for allocators like malloc where each allocation has to be freed on its own.
// No need to use it for allocators like Arena.
void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str);
void wapp_str8_dealloc_buf(const Allocator *allocator, WpStr8 **str);
/**
* Str8 utilities
* WpStr8 utilities
*/
c8 wapp_str8_get(Str8RO *str, u64 index);
void wapp_str8_set(Str8 *str, u64 index, c8 c);
void wapp_str8_push_back(Str8 *str, c8 c);
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2);
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count);
Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end);
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src);
void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src);
void wapp_str8_copy_str8_capped(Str8 *dst, Str8RO *src);
void wapp_str8_copy_to_cstr(char *dst, Str8RO *src, u64 dst_capacity);
void wapp_str8_format(Str8 *dst, const char *format, ...);
void wapp_str8_to_lower(Str8 *dst, Str8RO *src);
void wapp_str8_to_upper(Str8 *dst, Str8RO *src);
void wapp_str8_from_bytes(Str8 *dst, const U8Array src);
c8 wapp_str8_get(WpStr8RO *str, u64 index);
void wapp_str8_set(WpStr8 *str, u64 index, c8 c);
void wapp_str8_push_back(WpStr8 *str, c8 c);
b8 wapp_str8_equal(WpStr8RO *s1, WpStr8RO *s2);
b8 wapp_str8_equal_to_count(WpStr8RO* s1, WpStr8RO* s2, u64 count);
WpStr8 wapp_str8_slice(WpStr8RO *str, u64 start, u64 end);
void wapp_str8_concat_capped(WpStr8 *dst, WpStr8RO *src);
void wapp_str8_copy_cstr_capped(WpStr8 *dst, const char *src);
void wapp_str8_copy_str8_capped(WpStr8 *dst, WpStr8RO *src);
void wapp_str8_copy_to_cstr(char *dst, WpStr8RO *src, u64 dst_capacity);
void wapp_str8_format(WpStr8 *dst, const char *format, ...);
void wapp_str8_to_lower(WpStr8 *dst, WpStr8RO *src);
void wapp_str8_to_upper(WpStr8 *dst, WpStr8RO *src);
void wapp_str8_from_bytes(WpStr8 *dst, const U8Array src);
/**
* Str8 find functions
* WpStr8 find functions
*/
i64 wapp_str8_find(Str8RO *str, Str8RO substr);
i64 wapp_str8_rfind(Str8RO *str, Str8RO substr);
i64 wapp_str8_find(WpStr8RO *str, WpStr8RO substr);
i64 wapp_str8_rfind(WpStr8RO *str, WpStr8RO substr);
/**
* Str8 split and join
* WpStr8 split and join
*/
#define wapp_str8_split(ALLOCATOR, STR, DELIMITER) wapp_str8_split_with_max(ALLOCATOR, STR, DELIMITER, -1)
#define wapp_str8_rsplit(ALLOCATOR, STR, DELIMITER) wapp_str8_rsplit_with_max(ALLOCATOR, STR, DELIMITER, -1)
Str8List *wapp_str8_split_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits);
Str8List *wapp_str8_rsplit_with_max(const Allocator *allocator, Str8RO *str, Str8RO *delimiter, i64 max_splits);
Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *delimiter);
WpStr8List *wapp_str8_split_with_max(const Allocator *allocator, WpStr8RO *str, WpStr8RO *delimiter, i64 max_splits);
WpStr8List *wapp_str8_rsplit_with_max(const Allocator *allocator, WpStr8RO *str, WpStr8RO *delimiter, i64 max_splits);
WpStr8 *wapp_str8_join(const Allocator *allocator, const WpStr8List *list, WpStr8RO *delimiter);
/**
* Str8 list utilities
* WpStr8 list utilities
*/
u64 wapp_str8_list_total_size(const Str8List *list);
u64 wapp_str8_list_total_size(const WpStr8List *list);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+19 -19
View File
@@ -11,9 +11,9 @@
#define MIN_LOG_MSG_LENGTH 32
#define TIME_BUF_CAPACITY 70
wp_intern Str8RO L_BRACKET = wapp_str8_lit_ro("[");
wp_intern Str8RO R_BRACKET_SPACE = wapp_str8_lit_ro("] ");
wp_intern Str8RO R_BRACKET_NEWLINE = wapp_str8_lit_ro("]\n");
wp_intern WpStr8RO L_BRACKET = wapp_str8_lit_ro("[");
wp_intern WpStr8RO R_BRACKET_SPACE = wapp_str8_lit_ro("] ");
wp_intern WpStr8RO R_BRACKET_NEWLINE = wapp_str8_lit_ro("]\n");
typedef struct {
WFile *outlog;
@@ -26,7 +26,7 @@ typedef struct {
wp_intern LogConfig LOG_CONFIG = {
.level = WP_LOG_LEVEL_DEBUG,
};
wp_intern Str8RO LOG_LEVEL_STRINGS[COUNT_LOG_LEVEL] = {
wp_intern WpStr8RO LOG_LEVEL_STRINGS[COUNT_LOG_LEVEL] = {
[WP_LOG_LEVEL_FATAL] = wapp_str8_lit_ro_initialiser_list("fatal "),
[WP_LOG_LEVEL_CRITICAL] = wapp_str8_lit_ro_initialiser_list("critical "),
[WP_LOG_LEVEL_ERROR] = wapp_str8_lit_ro_initialiser_list("error "),
@@ -35,8 +35,8 @@ wp_intern Str8RO LOG_LEVEL_STRINGS[COUNT_LOG_LEVEL] = {
[WP_LOG_LEVEL_DEBUG] = wapp_str8_lit_ro_initialiser_list("debug "),
};
wp_intern void _get_current_time_string(Str8 *dst);
wp_intern void _write_log_line(WFile *fp, const WpLogger *logger, Str8 msg, LogLevel level);
wp_intern void _get_current_time_string(WpStr8 *dst);
wp_intern void _write_log_line(WFile *fp, const WpLogger *logger, WpStr8 msg, LogLevel level);
void wpLogSetLevel(LogLevel level) {
LOG_CONFIG.level = level;
@@ -48,11 +48,11 @@ void wpLogConfigure(WFile *outlog, WFile *errlog, LogLevel level) {
LOG_CONFIG.level = level;
}
WpLogger wpLogMakeLogger(Str8 name) {
WpLogger wpLogMakeLogger(WpStr8 name) {
return (WpLogger){ .name = name };
}
void wpLogDebug(const WpLogger *logger, Str8 msg) {
void wpLogDebug(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_DEBUG) { return; }
@@ -60,7 +60,7 @@ void wpLogDebug(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_DEBUG);
}
void wpLogInfo(const WpLogger *logger, Str8 msg) {
void wpLogInfo(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_INFO) { return; }
@@ -68,7 +68,7 @@ void wpLogInfo(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_INFO);
}
void wpLogWarning(const WpLogger *logger, Str8 msg) {
void wpLogWarning(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_WARNING) { return; }
@@ -76,7 +76,7 @@ void wpLogWarning(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_WARNING);
}
void wpLogError(const WpLogger *logger, Str8 msg) {
void wpLogError(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_ERROR) { return; }
@@ -84,7 +84,7 @@ void wpLogError(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_ERROR);
}
void wpLogCritical(const WpLogger *logger, Str8 msg) {
void wpLogCritical(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_CRITICAL) { return; }
@@ -92,7 +92,7 @@ void wpLogCritical(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_CRITICAL);
}
void wpLogFatal(const WpLogger *logger, Str8 msg) {
void wpLogFatal(const WpLogger *logger, WpStr8 msg) {
wpDebugAssert(logger != NULL, "`logger` should not be NULL");
if (LOG_CONFIG.level < WP_LOG_LEVEL_FATAL) { return; }
@@ -100,7 +100,7 @@ void wpLogFatal(const WpLogger *logger, Str8 msg) {
_write_log_line(fp, logger, msg, WP_LOG_LEVEL_FATAL);
}
wp_intern void _get_current_time_string(Str8 *dst) {
wp_intern void _get_current_time_string(WpStr8 *dst) {
// TODO (Abdelrahman): Replace with proper date/time utilities
char buf[TIME_BUF_CAPACITY];
time_t now = time(NULL);
@@ -110,16 +110,16 @@ wp_intern void _get_current_time_string(Str8 *dst) {
wapp_str8_copy_cstr_capped(dst, buf);
}
wp_intern void _write_log_line(WFile *fp, const WpLogger *logger, Str8 msg, LogLevel level) {
Str8 padding = wapp_str8_buf(MIN_LOG_MSG_LENGTH);
wp_intern void _write_log_line(WFile *fp, const WpLogger *logger, WpStr8 msg, LogLevel level) {
WpStr8 padding = wapp_str8_buf(MIN_LOG_MSG_LENGTH);
u32 padding_size = msg.size < MIN_LOG_MSG_LENGTH ? MIN_LOG_MSG_LENGTH - msg.size + 1 : 0;
wapp_str8_format(&padding, "%-*s", padding_size, " ");
Str8 time_str = wapp_str8_buf(TIME_BUF_CAPACITY);
WpStr8 time_str = wapp_str8_buf(TIME_BUF_CAPACITY);
_get_current_time_string(&time_str);
Str8RO **strings = wapp_array(
Str8RO *,
WpStr8RO **strings = wapp_array(
WpStr8RO *,
&time_str,
&L_BRACKET,
&LOG_LEVEL_STRINGS[level],
+8 -8
View File
@@ -18,17 +18,17 @@ typedef enum {
} LogLevel;
typedef struct {
Str8 name;
WpStr8 name;
} WpLogger;
void wpLogSetLevel(LogLevel level);
void wpLogConfigure(WFile *outlog, WFile *errlog, LogLevel level);
WpLogger wpLogMakeLogger(Str8 name);
void wpLogDebug(const WpLogger *logger, Str8 msg);
void wpLogInfo(const WpLogger *logger, Str8 msg);
void wpLogWarning(const WpLogger *logger, Str8 msg);
void wpLogError(const WpLogger *logger, Str8 msg);
void wpLogCritical(const WpLogger *logger, Str8 msg);
void wpLogFatal(const WpLogger *logger, Str8 msg);
WpLogger wpLogMakeLogger(WpStr8 name);
void wpLogDebug(const WpLogger *logger, WpStr8 msg);
void wpLogInfo(const WpLogger *logger, WpStr8 msg);
void wpLogWarning(const WpLogger *logger, WpStr8 msg);
void wpLogError(const WpLogger *logger, WpStr8 msg);
void wpLogCritical(const WpLogger *logger, WpStr8 msg);
void wpLogFatal(const WpLogger *logger, WpStr8 msg);
#endif // !LOG_H
+11 -11
View File
@@ -11,7 +11,7 @@
#include <stdio.h>
#include <string.h>
u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts) {
if (!dst || !parts) {
return CPATH_JOIN_INVALID_ARGS;
}
@@ -20,7 +20,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
return CPATH_JOIN_EMPTY_PARTS;
}
Str8 separator = wapp_str8_buf(4);
WpStr8 separator = wapp_str8_buf(4);
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
u64 required_capacity = parts->node_count * separator.size + wapp_str8_list_total_size(parts);
@@ -29,16 +29,16 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
}
// Handle first node
Str8 *first_node = wapp_dbl_list_get(Str8, parts, 0);
WpStr8 *first_node = wapp_dbl_list_get(WpStr8, parts, 0);
wapp_str8_copy_str8_capped(dst, first_node);
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
Str8 *node = first_node;
WpStr8 *node = first_node;
u64 node_index = 1;
b8 running = node_index < parts->node_count;
while (running) {
node = wapp_dbl_list_get(Str8, parts, node_index);
node = wapp_dbl_list_get(WpStr8, parts, node_index);
if (node->size == 0) {
goto CPATH_JOIN_LOOP_END;
}
@@ -63,14 +63,14 @@ CPATH_JOIN_LOOP_END:
return CPATH_JOIN_SUCCESS;
}
Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
Str8 *output = NULL;
WpStr8 *dirup(const Allocator *allocator, WpStr8RO *path, u64 levels) {
WpStr8 *output = NULL;
if (!allocator || !path) {
goto RETURN_DIRUP;
}
b8 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
Str8 separator = wapp_str8_buf(4);
WpStr8 separator = wapp_str8_buf(4);
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
if (path->size == 0) {
@@ -93,7 +93,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
goto RETURN_DIRUP;
}
Str8List *parts = wapp_str8_split(&tmp_arena, path, &separator);
WpStr8List *parts = wapp_str8_split(&tmp_arena, path, &separator);
if (!parts) {
goto RETURN_DIRUP;
}
@@ -107,7 +107,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
wapp_str8_push_back(output, absolute ? WAPP_PATH_SEP : '.');
} else {
for (u64 i = 0; i < levels; ++i) {
wapp_dbl_list_pop_back(Str8, parts);
wapp_dbl_list_pop_back(WpStr8, parts);
}
u64 alignment = sizeof(void *) * 2;
@@ -121,7 +121,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
wapp_str8_push_back(output, WAPP_PATH_SEP);
}
Str8 *joined = wapp_str8_join(&tmp_arena, parts, &separator);
WpStr8 *joined = wapp_str8_join(&tmp_arena, parts, &separator);
if (joined) {
wapp_str8_concat_capped(output, joined);
}
+2 -2
View File
@@ -35,8 +35,8 @@ enum {
CPATH_JOIN_INSUFFICIENT_DST_CAPACITY,
};
u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts);
Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels);
u32 wapp_cpath_join_path(WpStr8 *dst, const WpStr8List *parts);
WpStr8 *dirup(const Allocator *allocator, WpStr8RO *path, u64 levels);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+5 -5
View File
@@ -7,7 +7,7 @@
#include "../../base/array/array.h"
#include "../../base/strings/str8/str8.h"
WFile *wapp_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
WFile *wapp_file_open(const Allocator *allocator, WpStr8RO *filepath, FileAccessMode mode) {
wpDebugAssert(allocator != NULL && filepath != NULL, "`allocator` and `filepath` should not be NULL");
wpDebugAssert(filepath->size < WAPP_PATH_MAX, "`filepath` exceeds max path limit.");
return _file_open(allocator, filepath, mode);
@@ -56,12 +56,12 @@ i64 wapp_file_write(const void *src_buf, WFile *file, u64 byte_count) {
return _file_write(src_buf, file, byte_count);
}
u64 wapp_file_read_str8(Str8 *str, WFile *file) {
u64 wapp_file_read_str8(WpStr8 *str, WFile *file) {
wpDebugAssert(str != NULL, "`str` should not be NULL.");
return wapp_file_read((void *)(str->buf), file, str->size);
}
i64 wapp_file_write_str8(Str8RO *str, WFile *file) {
i64 wapp_file_write_str8(WpStr8RO *str, WFile *file) {
wpDebugAssert(str != NULL, "`str` should not be NULL.");
return wapp_file_write((void *)(str->buf), file, str->size);
}
@@ -124,7 +124,7 @@ i32 wapp_file_close(WFile *file) {
return _file_close(file);
}
i32 wapp_file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
i32 wapp_file_rename(WpStr8RO *old_filepath, WpStr8RO *new_filepath) {
wpDebugAssert(old_filepath != NULL && new_filepath != NULL,
"`old_filepath` and `new_filepath` should not be NULL");
wpDebugAssert(old_filepath->size < WAPP_PATH_MAX, "`old_filepath` exceeds max path limit.");
@@ -132,7 +132,7 @@ i32 wapp_file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
return _file_rename(old_filepath, new_filepath);
}
i32 wapp_file_remove(Str8RO *filepath) {
i32 wapp_file_remove(WpStr8RO *filepath) {
wpDebugAssert(filepath != NULL, "`filepath` should not be NULL");
wpDebugAssert(filepath->size < WAPP_PATH_MAX, "`filepath` exceeds max path limit.");
return _file_remove(filepath);
+8 -8
View File
@@ -46,29 +46,29 @@ wp_extern WFile *wapp_file_stdout(void);
// wapp_file_stderr to get the standard error stream
wp_extern WFile *wapp_file_stderr(void);
WFile *wapp_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode);
WFile *wapp_file_open(const Allocator *allocator, WpStr8RO *filepath, FileAccessMode mode);
i64 wapp_file_get_current_position(WFile *file);
i64 wapp_file_seek(WFile *file, i64 offset, FileSeekOrigin origin);
i64 wapp_file_get_length(WFile *file);
u64 wapp_file_read(void *dst_buf, WFile *file, u64 byte_count);
i64 wapp_file_write(const void *src_buf, WFile *file, u64 byte_count);
u64 wapp_file_read_str8(Str8 *str, WFile *file);
i64 wapp_file_write_str8(Str8RO *str, WFile *file);
u64 wapp_file_read_str8(WpStr8 *str, WFile *file);
i64 wapp_file_write_str8(WpStr8RO *str, WFile *file);
u64 wapp_file_read_array(GenericArray dst_buf, WFile *file, u64 item_count);
i64 wapp_file_write_array(const GenericArray src_buf, WFile *file, u64 item_count);
i32 wapp_file_flush(WFile *file);
i32 wapp_file_close(WFile *file);
i32 wapp_file_rename(Str8RO *old_filepath, Str8RO *new_filepath);
i32 wapp_file_remove(Str8RO *filepath);
i32 wapp_file_rename(WpStr8RO *old_filepath, WpStr8RO *new_filepath);
i32 wapp_file_remove(WpStr8RO *filepath);
wp_extern WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode);
wp_extern WFile *_file_open(const Allocator *allocator, WpStr8RO *filepath, FileAccessMode mode);
wp_extern i64 _file_seek(WFile *file, i64 offset, FileSeekOrigin origin);
wp_extern u64 _file_read(void *dst_buf, u64 byte_count, WFile *file, u64 file_length);
wp_extern i64 _file_write(const void *src_buf, WFile *file, u64 byte_count);
wp_extern i32 _file_flush(WFile *file);
wp_extern i32 _file_close(WFile *file);
wp_extern i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath);
wp_extern i32 _file_remove(Str8RO *filepath);
wp_extern i32 _file_rename(WpStr8RO *old_filepath, WpStr8RO *new_filepath);
wp_extern i32 _file_remove(WpStr8RO *filepath);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+3 -3
View File
@@ -64,7 +64,7 @@ WFile *wapp_file_stderr(void) {
return &_stderr;
}
WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
WFile *_file_open(const Allocator *allocator, WpStr8RO *filepath, FileAccessMode mode) {
wp_persist c8 tmp[WAPP_PATH_MAX] = {0};
memset(tmp, 0, WAPP_PATH_MAX);
memcpy(tmp, filepath->buf, filepath->size);
@@ -107,7 +107,7 @@ i32 _file_close(WFile *file) {
return close(file->fd);
}
i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
i32 _file_rename(WpStr8RO *old_filepath, WpStr8RO *new_filepath) {
wp_persist c8 old_tmp[WAPP_PATH_MAX] = {0};
wp_persist c8 new_tmp[WAPP_PATH_MAX] = {0};
memset(old_tmp, 0, WAPP_PATH_MAX);
@@ -123,7 +123,7 @@ i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
return link_result;
}
i32 _file_remove(Str8RO *filepath) {
i32 _file_remove(WpStr8RO *filepath) {
wp_persist c8 tmp[WAPP_PATH_MAX] = {0};
memset(tmp, 0, WAPP_PATH_MAX);
memcpy(tmp, filepath->buf, filepath->size);
+3 -3
View File
@@ -72,7 +72,7 @@ WFile *wapp_file_stderr(void) {
return &_stderr;
}
WFile *_file_open(const Allocator *allocator, Str8RO *filepath, FileAccessMode mode) {
WFile *_file_open(const Allocator *allocator, WpStr8RO *filepath, FileAccessMode mode) {
wp_persist c8 tmp[WAPP_PATH_MAX] = {0};
memset(tmp, 0, WAPP_PATH_MAX);
memcpy(tmp, filepath->buf, filepath->size);
@@ -147,7 +147,7 @@ i32 _file_close(WFile *file) {
return 0;
}
i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
i32 _file_rename(WpStr8RO *old_filepath, WpStr8RO *new_filepath) {
wp_persist c8 old_tmp[WAPP_PATH_MAX] = {0};
wp_persist c8 new_tmp[WAPP_PATH_MAX] = {0};
memset(old_tmp, 0, WAPP_PATH_MAX);
@@ -162,7 +162,7 @@ i32 _file_rename(Str8RO *old_filepath, Str8RO *new_filepath) {
return 0;
}
i32 _file_remove(Str8RO *filepath) {
i32 _file_remove(WpStr8RO *filepath) {
wp_persist c8 tmp[WAPP_PATH_MAX] = {0};
memset(tmp, 0, WAPP_PATH_MAX);
memcpy(tmp, filepath->buf, filepath->size);
+8 -8
View File
@@ -17,17 +17,17 @@
#define CMD_BUF_LEN 8192
#define OUT_BUF_LEN 4096
wp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf);
wp_intern CMDResult execute_command(WpStr8RO *cmd, CMDOutHandling out_handling, WpStr8 *out_buf);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, WpStr8 *out_buf);
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd) {
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd) {
if (!cmd) {
return CMD_NO_EXIT(SHELL_ERR_INVALID_ARGS);
}
Allocator arena = wapp_mem_arena_allocator_init(KiB(500));
Str8 *cmd_str = wapp_str8_join(&arena, cmd, &wapp_str8_lit_ro(" "));
WpStr8 *cmd_str = wapp_str8_join(&arena, cmd, &wapp_str8_lit_ro(" "));
if (!cmd_str) {
wapp_mem_arena_allocator_destroy(&arena);
return CMD_NO_EXIT(SHELL_ERR_ALLOCATION_FAIL);
@@ -43,7 +43,7 @@ CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_bu
return output;
}
wp_intern CMDResult execute_command(Str8RO *cmd, CMDOutHandling out_handling, Str8 *out_buf) {
wp_intern CMDResult execute_command(WpStr8RO *cmd, CMDOutHandling out_handling, WpStr8 *out_buf) {
char cmd_buf[CMD_BUF_LEN] = {0};
wapp_str8_copy_to_cstr(cmd_buf, cmd, CMD_BUF_LEN);
@@ -83,8 +83,8 @@ EXECUTE_COMMAND_CLOSE:
return output;
}
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str8 *out_buf) {
Str8 out = wapp_str8_buf(OUT_BUF_LEN);
wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, WpStr8 *out_buf) {
WpStr8 out = wapp_str8_buf(OUT_BUF_LEN);
out.size = fread((void *)out.buf, sizeof(c8), out.capacity, fp);
if (out_handling == SHELL_OUTPUT_CAPTURE && out_buf != NULL) {
@@ -94,7 +94,7 @@ wp_intern CMDError get_command_output(FILE *fp, CMDOutHandling out_handling, Str
wapp_str8_concat_capped(out_buf, &out);
} else if (out_handling == SHELL_OUTPUT_PRINT) {
printf(WAPP_STR8_SPEC, wapp_str8_varg(out));
printf(WP_STR8_SPEC, wpStr8Varg(out));
}
return SHELL_ERR_NO_ERROR;
+1 -1
View File
@@ -18,7 +18,7 @@ BEGIN_C_LINKAGE
#define CMD_NO_EXIT(ERR) ((CMDResult){.exited = false, .exit_code = EXIT_FAILURE, .error = ERR})
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, Str8 *out_buf, const Str8List *cmd);
CMDResult wapp_shell_commander_execute(CMDOutHandling out_handling, WpStr8 *out_buf, const WpStr8List *cmd);
wp_extern CMDError get_output_status(FILE *fp, i32 *status_out);
@@ -9,7 +9,7 @@
#include "../terminal_colours.h"
#include <stdio.h>
wp_intern Str8RO colours[COUNT_TERM_COLOUR] = {
wp_intern WpStr8RO colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_FG_BLACK] = wapp_str8_lit_ro_initialiser_list("\033[30m"),
[WAPP_TERM_COLOUR_FG_RED] = wapp_str8_lit_ro_initialiser_list("\033[31m"),
[WAPP_TERM_COLOUR_FG_GREEN] = wapp_str8_lit_ro_initialiser_list("\033[32m"),
@@ -29,8 +29,8 @@ wp_intern Str8RO colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_CLEAR] = wapp_str8_lit_ro_initialiser_list("\033[0m"),
};
void print_coloured_text(Str8RO *text, TerminalColour colour) {
printf(WAPP_STR8_SPEC WAPP_STR8_SPEC, wapp_str8_varg(colours[colour]), wapp_str8_varg((*text)));
void print_coloured_text(WpStr8RO *text, TerminalColour colour) {
printf(WP_STR8_SPEC WP_STR8_SPEC, wpStr8Varg(colours[colour]), wpStr8Varg((*text)));
}
#endif // !WP_PLATFORM_POSIX
+2 -2
View File
@@ -4,7 +4,7 @@
#include "terminal_colours.h"
#include "../../../base/strings/str8/str8.h"
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour) {
void wapp_shell_termcolour_print_text(WpStr8RO *text, TerminalColour colour) {
if (colour < WAPP_TERM_COLOUR_FG_BLACK || colour > WAPP_TERM_COLOUR_FG_BR_WHITE) {
return;
}
@@ -13,6 +13,6 @@ void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour) {
}
void wapp_shell_termcolour_clear_colour(void) {
Str8RO empty = wapp_str8_lit_ro("");
WpStr8RO empty = wapp_str8_lit_ro("");
print_coloured_text(&empty, WAPP_TERM_COLOUR_CLEAR);
}
+2 -2
View File
@@ -14,10 +14,10 @@ BEGIN_C_LINKAGE
// TODO (Abdelrahman): Look into moving away from stdio in the implementation
void wapp_shell_termcolour_print_text(Str8RO *text, TerminalColour colour);
void wapp_shell_termcolour_print_text(WpStr8RO *text, TerminalColour colour);
void wapp_shell_termcolour_clear_colour(void);
wp_extern void print_coloured_text(Str8RO *text, TerminalColour colour);
wp_extern void print_coloured_text(WpStr8RO *text, TerminalColour colour);
#ifdef WP_PLATFORM_CPP
END_C_LINKAGE
+2 -2
View File
@@ -43,7 +43,7 @@ wp_intern WORD colours[COUNT_TERM_COLOUR] = {
[WAPP_TERM_COLOUR_FG_BR_WHITE] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY,
};
void print_coloured_text(Str8RO *text, TerminalColour colour) {
void print_coloured_text(WpStr8RO *text, TerminalColour colour) {
wp_persist TermcolourData data = {0};
if (data.handle == 0) {
init_data(&data);
@@ -56,7 +56,7 @@ void print_coloured_text(Str8RO *text, TerminalColour colour) {
}
SetConsoleTextAttribute(data.handle, data.current_colour);
printf(WAPP_STR8_SPEC, wapp_str8_varg((*text)));
printf(WP_STR8_SPEC, wpStr8Varg((*text)));
}
wp_intern void init_data(TermcolourData *data) {
+2 -2
View File
@@ -34,7 +34,7 @@ void _runTests(WpTestFunc *func1, ...) {
wp_intern void handleTestResult(WpTestFuncResult result) {
TerminalColour colour;
Str8 result_text = wapp_str8_buf(64);
WpStr8 result_text = wapp_str8_buf(64);
if (result.passed) {
colour = WAPP_TERM_COLOUR_FG_BR_GREEN;
@@ -47,7 +47,7 @@ wp_intern void handleTestResult(WpTestFuncResult result) {
printf("[");
wapp_shell_termcolour_print_text(&result_text, colour);
wapp_shell_termcolour_clear_colour();
printf("] " WAPP_STR8_SPEC "\n", wapp_str8_varg(result.name));
printf("] " WP_STR8_SPEC "\n", wpStr8Varg(result.name));
if (!result.passed) {
exit(EXIT_FAILURE);
+2 -2
View File
@@ -19,10 +19,10 @@ BEGIN_C_LINKAGE
typedef struct WpTestFuncResult WpTestFuncResult;
struct WpTestFuncResult {
Str8 name;
WpStr8 name;
b8 passed;
wpMiscUtilsReservePadding(sizeof(Str8) + sizeof(b8));
wpMiscUtilsReservePadding(sizeof(WpStr8) + sizeof(b8));
};
typedef WpTestFuncResult(WpTestFunc)(void);
+3 -3
View File
@@ -12,12 +12,12 @@ BEGIN_C_LINKAGE
#endif // !WP_PLATFORM_CPP
#define WP_UUID_BUF_LENGTH 48
#define WP_UUID_SPEC WAPP_STR8_SPEC
#define wpUuidVarg(WpUuid) wapp_str8_varg((WpUuid).uuid)
#define WP_UUID_SPEC WP_STR8_SPEC
#define wpUuidVarg(WpUuid) wpStr8Varg((WpUuid).uuid)
typedef struct WpUuid WpUuid;
struct WpUuid {
Str8 uuid;
WpStr8 uuid;
};
// TODO (Abdelrahman): Update UUID implementation to work properly with C++ and tests for validation
+4 -4
View File
@@ -5,16 +5,16 @@
WpTestFuncResult test_str8_array(void) {
b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
Str8Array array = wapp_array(Str8, wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye"));
WpStr8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
WpStr8Array array = wapp_array(WpStr8, wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye"));
result = wapp_array_count(array) == 3 && wapp_array_capacity(array) == 8;
Str8 *item;
WpStr8 *item;
u64 count = wapp_array_count(array);
u64 index = 0;
b8 running = true;
while (running) {
item = wapp_array_get(Str8, array, index);
item = wapp_array_get(WpStr8, array, index);
result = result && item && (wapp_str8_equal(item, &expected[index]));
++index;
+7 -7
View File
@@ -5,21 +5,21 @@
WpTestFuncResult test_str8_array(void) {
b8 result;
Str8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
WpStr8 expected[] = {wapp_str8_lit("Hello"), wapp_str8_lit("Hi"), wapp_str8_lit("Bye")};
Str8 str1 = wapp_str8_lit("Hello");
Str8 str2 = wapp_str8_lit("Hi");
Str8 str3 = wapp_str8_lit("Bye");
Str8Array array = wapp_array(Str8, str1, str2, str3);
WpStr8 str1 = wapp_str8_lit("Hello");
WpStr8 str2 = wapp_str8_lit("Hi");
WpStr8 str3 = wapp_str8_lit("Bye");
WpStr8Array array = wapp_array(WpStr8, str1, str2, str3);
result = wapp_array_count(array) == 3 && wapp_array_capacity(array) == 8;
Str8 *item;
WpStr8 *item;
u64 count = wapp_array_count(array);
u64 index = 0;
b8 running = true;
while (running) {
item = wapp_array_get(Str8, array, index);
item = wapp_array_get(WpStr8, array, index);
result = result && item && (wapp_str8_equal(item, &expected[index]));
++index;
+26 -26
View File
@@ -9,23 +9,23 @@
WpTestFuncResult test_cpath_join_path(void) {
b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 out = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
Str8List parts = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &parts, &tmp);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("abdelrahman"));
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("Documents"));
WpStr8List parts = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("abdelrahman"));
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("Documents"));
wapp_cpath_join_path(&out, &parts);
result = wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
@@ -33,8 +33,8 @@ WpTestFuncResult test_cpath_join_path(void) {
result = result && wapp_str8_equal(&out, &expected);
wapp_str8_concat_capped(&tmp, &wapp_str8_lit_ro("home"));
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_push_front(Str8, &parts, &tmp);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_front(WpStr8, &parts, &tmp);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
@@ -42,35 +42,35 @@ WpTestFuncResult test_cpath_join_path(void) {
result = result && wapp_str8_equal(&out, &expected);
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_push_front(Str8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_front(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_empty(Str8, &parts);
wapp_dbl_list_empty(WpStr8, &parts);
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
wapp_dbl_list_push_back(Str8, &parts, &tmp);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit(""));
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit(""));
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit(""));
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit(""));
wapp_str8_format(&expected, "%s", "");
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_back(Str8, &parts);
wapp_dbl_list_push_back(Str8, &parts, &wapp_str8_lit("home"));
wapp_dbl_list_pop_back(WpStr8, &parts);
wapp_dbl_list_push_back(WpStr8, &parts, &wapp_str8_lit("home"));
wapp_str8_copy_cstr_capped(&expected, "home");
@@ -87,10 +87,10 @@ WpTestFuncResult test_cpath_dirname(void) {
}
b8 result;
Str8 *output = NULL;
WpStr8 *output = NULL;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
@@ -135,10 +135,10 @@ WpTestFuncResult test_cpath_dirup(void) {
}
b8 result;
Str8 *output = NULL;
WpStr8 *output = NULL;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
+35 -35
View File
@@ -9,41 +9,41 @@
WpTestFuncResult test_cpath_join_path(void) {
b8 result;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 out = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 out = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
Str8List parts = wapp_dbl_list(Str8);
WpStr8List parts = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
Str8 home = wapp_str8_lit("home");
wapp_dbl_list_push_back(Str8, &parts, &home);
WpStr8 home = wapp_str8_lit("home");
wapp_dbl_list_push_back(WpStr8, &parts, &home);
Str8 user = wapp_str8_lit("abdelrahman");
wapp_dbl_list_push_back(Str8, &parts, &user);
WpStr8 user = wapp_str8_lit("abdelrahman");
wapp_dbl_list_push_back(WpStr8, &parts, &user);
Str8 docs = wapp_str8_lit("Documents");
wapp_dbl_list_push_back(Str8, &parts, &docs);
WpStr8 docs = wapp_str8_lit("Documents");
wapp_dbl_list_push_back(WpStr8, &parts, &docs);
wapp_cpath_join_path(&out, &parts);
result = wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
Str8RO str = wapp_str8_lit_ro("home");
WpStr8RO str = wapp_str8_lit_ro("home");
wapp_str8_concat_capped(&tmp, &str);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_pop_front(WpStr8, &parts);
wapp_dbl_list_push_front(Str8, &parts, &tmp);
wapp_dbl_list_push_front(WpStr8, &parts, &tmp);
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
@@ -51,44 +51,44 @@ WpTestFuncResult test_cpath_join_path(void) {
result = result && wapp_str8_equal(&out, &expected);
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_pop_front(WpStr8, &parts);
Str8 home_2 = wapp_str8_lit("home");
wapp_dbl_list_push_front(Str8, &parts, &home_2);
WpStr8 home_2 = wapp_str8_lit("home");
wapp_dbl_list_push_front(WpStr8, &parts, &home_2);
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_empty(Str8, &parts);
wapp_dbl_list_empty(WpStr8, &parts);
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
wapp_dbl_list_push_back(Str8, &parts, &tmp);
wapp_dbl_list_push_back(WpStr8, &parts, &tmp);
Str8 empty = wapp_str8_lit("");
wapp_dbl_list_push_back(Str8, &parts, &empty);
WpStr8 empty = wapp_str8_lit("");
wapp_dbl_list_push_back(WpStr8, &parts, &empty);
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_front(Str8, &parts);
wapp_dbl_list_pop_front(WpStr8, &parts);
Str8 empty_2 = wapp_str8_lit("");
wapp_dbl_list_push_back(Str8, &parts, &empty_2);
WpStr8 empty_2 = wapp_str8_lit("");
wapp_dbl_list_push_back(WpStr8, &parts, &empty_2);
wapp_str8_format(&expected, "%s", "");
wapp_cpath_join_path(&out, &parts);
result = result && wapp_str8_equal(&out, &expected);
wapp_dbl_list_pop_back(Str8, &parts);
wapp_dbl_list_pop_back(WpStr8, &parts);
Str8 home_3 = wapp_str8_lit("home");
wapp_dbl_list_push_back(Str8, &parts, &home_3);
WpStr8 home_3 = wapp_str8_lit("home");
wapp_dbl_list_push_back(WpStr8, &parts, &home_3);
wapp_str8_copy_cstr_capped(&expected, "home");
@@ -105,10 +105,10 @@ WpTestFuncResult test_cpath_dirname(void) {
}
b8 result;
Str8 *output = nullptr;
WpStr8 *output = nullptr;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
@@ -120,7 +120,7 @@ WpTestFuncResult test_cpath_dirname(void) {
// CASE 2
wapp_str8_format(&expected, "%s", ".");
Str8 path = wapp_str8_lit("home");
WpStr8 path = wapp_str8_lit("home");
output = wapp_cpath_dirname(&arena, &path);
result = result && output != nullptr && wapp_str8_equal(output, &expected);
@@ -155,10 +155,10 @@ WpTestFuncResult test_cpath_dirup(void) {
}
b8 result;
Str8 *output = nullptr;
WpStr8 *output = nullptr;
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
WpStr8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
WpStr8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
// CASE 1
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
+2 -2
View File
@@ -4,8 +4,8 @@
#define DST_CAPACITY 5
wp_intern Allocator arena = {0};
wp_intern Str8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
wp_intern Str8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
wp_intern WpStr8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
wp_intern WpStr8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
wp_intern WFile *test_fp = NULL;
wp_intern I32Array src_array1 = wapp_array(i32, 0, 1, 2, 3, 4);
wp_intern I32Array src_array2 = wapp_array(i32, 5, 6, 7, 8, 9);
+2 -2
View File
@@ -4,8 +4,8 @@
#define DST_CAPACITY 5
wp_intern Allocator arena = {};
wp_intern Str8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
wp_intern Str8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
wp_intern WpStr8RO test_filename = wapp_str8_lit_ro_initialiser_list("wapptest.bin");
wp_intern WpStr8RO new_filename = wapp_str8_lit_ro_initialiser_list("wapptest2.bin");
wp_intern WFile *test_fp = NULL;
wp_intern i32 dst_buf[DST_CAPACITY] = {0};
wp_intern I32Array src_array1;
+15 -15
View File
@@ -5,9 +5,9 @@
#include <string.h>
WpTestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("hello world"));
WpStr8List cmd = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit("hello world"));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
@@ -17,8 +17,8 @@ WpTestFuncResult test_commander_cmd_success(void) {
}
WpTestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("grep"));
WpStr8List cmd = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit("grep"));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, NULL, &cmd);
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
@@ -28,14 +28,14 @@ WpTestFuncResult test_commander_cmd_failure(void) {
}
WpTestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64);
WpStr8 buf = wapp_str8_buf(64);
WpStr8 expected = wapp_str8_buf(64);
char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit(msg));
WpStr8List cmd = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit(msg));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
@@ -45,14 +45,14 @@ WpTestFuncResult test_commander_cmd_out_buf_success(void) {
}
WpTestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64);
WpStr8 buf = wapp_str8_buf(4);
WpStr8 expected = wapp_str8_buf(64);
char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(Str8, &cmd, &wapp_str8_lit(msg));
WpStr8List cmd = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit("echo"));
wapp_dbl_list_push_back(WpStr8, &cmd, &wapp_str8_lit(msg));
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
+22 -22
View File
@@ -5,11 +5,11 @@
#include <string.h>
WpTestFuncResult test_commander_cmd_success(void) {
Str8List cmd = wapp_dbl_list(Str8);
Str8 echo = wapp_str8_lit("echo");
Str8 msg = wapp_str8_lit("hello world");
wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &msg);
WpStr8List cmd = wapp_dbl_list(WpStr8);
WpStr8 echo = wapp_str8_lit("echo");
WpStr8 msg = wapp_str8_lit("hello world");
wapp_dbl_list_push_back(WpStr8, &cmd, &echo);
wapp_dbl_list_push_back(WpStr8, &cmd, &msg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
@@ -19,9 +19,9 @@ WpTestFuncResult test_commander_cmd_success(void) {
}
WpTestFuncResult test_commander_cmd_failure(void) {
Str8List cmd = wapp_dbl_list(Str8);
Str8 grep = wapp_str8_lit("grep");
wapp_dbl_list_push_back(Str8, &cmd, &grep);
WpStr8List cmd = wapp_dbl_list(WpStr8);
WpStr8 grep = wapp_str8_lit("grep");
wapp_dbl_list_push_back(WpStr8, &cmd, &grep);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_DISCARD, nullptr, &cmd);
b8 failed = result.exited && result.exit_code != EXIT_SUCCESS &&
@@ -31,16 +31,16 @@ WpTestFuncResult test_commander_cmd_failure(void) {
}
WpTestFuncResult test_commander_cmd_out_buf_success(void) {
Str8 buf = wapp_str8_buf(64);
Str8 expected = wapp_str8_buf(64);
WpStr8 buf = wapp_str8_buf(64);
WpStr8 expected = wapp_str8_buf(64);
char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8);
Str8 echo = wapp_str8_lit("echo");
Str8 arg = wapp_str8_lit(msg);
wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &arg);
WpStr8List cmd = wapp_dbl_list(WpStr8);
WpStr8 echo = wapp_str8_lit("echo");
WpStr8 arg = wapp_str8_lit(msg);
wapp_dbl_list_push_back(WpStr8, &cmd, &echo);
wapp_dbl_list_push_back(WpStr8, &cmd, &arg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 succeeded = result.exited && result.exit_code == EXIT_SUCCESS &&
@@ -50,16 +50,16 @@ WpTestFuncResult test_commander_cmd_out_buf_success(void) {
}
WpTestFuncResult test_commander_cmd_out_buf_failure(void) {
Str8 buf = wapp_str8_buf(4);
Str8 expected = wapp_str8_buf(64);
WpStr8 buf = wapp_str8_buf(4);
WpStr8 expected = wapp_str8_buf(64);
char msg[] = "hello world";
wapp_str8_copy_cstr_capped(&expected, msg);
Str8List cmd = wapp_dbl_list(Str8);
Str8 echo = wapp_str8_lit("echo");
Str8 arg = wapp_str8_lit(msg);
wapp_dbl_list_push_back(Str8, &cmd, &echo);
wapp_dbl_list_push_back(Str8, &cmd, &arg);
WpStr8List cmd = wapp_dbl_list(WpStr8);
WpStr8 echo = wapp_str8_lit("echo");
WpStr8 arg = wapp_str8_lit(msg);
wapp_dbl_list_push_back(WpStr8, &cmd, &echo);
wapp_dbl_list_push_back(WpStr8, &cmd, &arg);
CMDResult result = wapp_shell_commander_execute(SHELL_OUTPUT_CAPTURE, &buf, &cmd);
b8 failed = !result.exited && result.exit_code != EXIT_SUCCESS &&
+108 -108
View File
@@ -6,25 +6,25 @@
WpTestFuncResult test_str8_lit(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
result = s1.capacity == 22 && s1.capacity != s1.size;
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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 wpTesterResult(result);
@@ -33,25 +33,25 @@ WpTestFuncResult test_str8_lit(void) {
WpTestFuncResult test_str8_lit_ro(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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 wpTesterResult(result);
@@ -60,16 +60,16 @@ WpTestFuncResult test_str8_lit_ro(void) {
WpTestFuncResult test_str8_buf(void) {
b8 result;
Str8 s1 = wapp_str8_buf(1024);
WpStr8 s1 = wapp_str8_buf(1024);
result = s1.capacity == 1024 && s1.size == 0;
Str8 s2 = wapp_str8_buf(2048);
WpStr8 s2 = wapp_str8_buf(2048);
result = result && s2.capacity == 2048 && s2.size == 0;
Str8 s3 = wapp_str8_buf(4096);
WpStr8 s3 = wapp_str8_buf(4096);
result = result && s3.capacity == 4096 && s3.size == 0;
Str8 s4 = wapp_str8_buf(8192);
WpStr8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0;
return wpTesterResult(result);
@@ -84,7 +84,7 @@ WpTestFuncResult test_str8_alloc_buf(void) {
u64 capacity = 4096;
Str8 *s = wapp_str8_alloc_buf(&allocator, capacity);
WpStr8 *s = wapp_str8_alloc_buf(&allocator, capacity);
if (!s) {
result = false;
goto TEST_ALLOC_BUF_CLEANUP;
@@ -112,7 +112,7 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
char *str = "Abdelrahman";
u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
WpStr8 *s = wapp_str8_alloc_cstr(&allocator, str);
if (!s) {
return wpTesterResult(false);
}
@@ -131,8 +131,8 @@ WpTestFuncResult test_str8_alloc_str8(void) {
return wpTesterResult(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
WpStr8 str = wapp_str8_lit("Abdelrahman");
WpStr8 *s = wapp_str8_alloc_str8(&allocator, &str);
if (!s) {
return wpTesterResult(false);
}
@@ -151,8 +151,8 @@ WpTestFuncResult test_str8_alloc_substr(void) {
return wpTesterResult(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
WpStr8 str = wapp_str8_lit("Abdelrahman");
WpStr8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
if (!s) {
return wpTesterResult(false);
}
@@ -167,32 +167,32 @@ WpTestFuncResult test_str8_alloc_substr(void) {
WpTestFuncResult test_str8_get_index_within_bounds(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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 wpTesterResult(result);
}
WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0';
return wpTesterResult(result);
}
@@ -200,31 +200,31 @@ WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
WpTestFuncResult test_str8_set(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
wapp_str8_set(&s1, 4, 'f');
result = wapp_str8_get(&s1, 4) == 'f';
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
WpStr8 s2 = wapp_str8_lit("Different strokes for different folks");
wapp_str8_set(&s2, 0, 'A');
result = result && wapp_str8_get(&s2, 0) == 'A';
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
WpStr8 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';
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
WpStr8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
wapp_str8_set(&s4, 20, 'R');
result = result && wapp_str8_get(&s4, 20) == 'R';
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
WpStr8 s5 = wapp_str8_lit("Do as I say, not as I do");
wapp_str8_set(&s5, 11, '.');
result = result && wapp_str8_get(&s5, 11) == '.';
Str8 s6 = wapp_str8_lit("Do as you would be done by");
WpStr8 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';
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
WpStr8 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';
@@ -234,8 +234,8 @@ WpTestFuncResult test_str8_set(void) {
WpTestFuncResult test_str8_push_back(void) {
b8 result;
Str8 expected = wapp_str8_lit("Abdelrahman");
Str8 buf = wapp_str8_buf(64);
WpStr8 expected = wapp_str8_lit("Abdelrahman");
WpStr8 buf = wapp_str8_buf(64);
wapp_str8_push_back(&buf, 'A');
wapp_str8_push_back(&buf, 'b');
wapp_str8_push_back(&buf, 'd');
@@ -256,10 +256,10 @@ WpTestFuncResult test_str8_push_back(void) {
WpTestFuncResult test_str8_equal(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("hello");
Str8RO s2 = wapp_str8_lit_ro("hell");
Str8RO s3 = wapp_str8_lit_ro("hello");
Str8RO s4 = wapp_str8_lit_ro("goodbye");
WpStr8RO s1 = wapp_str8_lit_ro("hello");
WpStr8RO s2 = wapp_str8_lit_ro("hell");
WpStr8RO s3 = wapp_str8_lit_ro("hello");
WpStr8RO s4 = wapp_str8_lit_ro("goodbye");
result = wapp_str8_equal(&s1, &s2) == false;
result = result && wapp_str8_equal(&s1, &s3) == true;
@@ -270,18 +270,18 @@ WpTestFuncResult test_str8_equal(void) {
WpTestFuncResult test_str8_slice(void) {
b8 result;
Str8 s = wapp_str8_lit("Different strokes for different folks");
WpStr8 s = wapp_str8_lit("Different strokes for different folks");
Str8RO sub1 = wapp_str8_slice(&s, 3, 9);
WpStr8RO sub1 = wapp_str8_slice(&s, 3, 9);
result = sub1.size == 6 && sub1.capacity == 6;
Str8RO sub2 = wapp_str8_slice(&s, 18, 21);
WpStr8RO sub2 = wapp_str8_slice(&s, 18, 21);
result = result && sub2.size == 3 && sub2.capacity == 3;
Str8RO sub3 = wapp_str8_slice(&s, 5, 1);
WpStr8RO sub3 = wapp_str8_slice(&s, 5, 1);
result = result && sub3.size == 0 && sub3.capacity == 0;
Str8RO sub4 = wapp_str8_slice(&s, 70, 80);
WpStr8RO sub4 = wapp_str8_slice(&s, 70, 80);
result = result && sub4.size == 0 && sub4.capacity == 0;
return wpTesterResult(result);
@@ -291,13 +291,13 @@ WpTestFuncResult 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.");
WpStr8 str = wapp_str8_lit("Hello world");
WpStr8 suffix1 = wapp_str8_lit(" from me.");
WpStr8 suffix2 = wapp_str8_lit(" This is my code.");
WpStr8 concat1 = wapp_str8_lit("Hello world from me.");
WpStr8 concat2 = wapp_str8_lit("Hello world from me. This is my code.");
Str8 *output;
WpStr8 *output;
output = wapp_str8_alloc_concat(&arena, &str, &suffix1);
result = output->size == concat1.size && wapp_str8_equal(output, &concat1);
@@ -313,11 +313,11 @@ WpTestFuncResult test_str8_alloc_concat(void) {
WpTestFuncResult 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");
WpStr8 str = wapp_str8_lit("Hello world");
WpStr8 suffix1 = wapp_str8_lit(" from me.");
WpStr8 suffix2 = wapp_str8_lit(" This is my code.");
WpStr8 concat1 = wapp_str8_lit("Hello world from me.");
WpStr8 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 @@ WpTestFuncResult test_str8_concat_capped(void) {
WpTestFuncResult test_str8_copy_cstr_capped(void) {
b8 result;
Str8 buf = wapp_str8_buf(32);
WpStr8 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");
WpStr8RO src1_cp = wapp_str8_lit_ro("Hello world");
WpStr8RO 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 @@ WpTestFuncResult test_str8_copy_cstr_capped(void) {
WpTestFuncResult 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");
WpStr8 buf = wapp_str8_buf(32);
WpStr8RO src1 = wapp_str8_lit_ro("Hello world");
WpStr8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library");
WpStr8RO 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 @@ WpTestFuncResult test_str8_copy_str8_capped(void) {
WpTestFuncResult 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");
WpStr8 buf = wapp_str8_buf(128);
WpStr8 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);
@@ -378,7 +378,7 @@ WpTestFuncResult test_str8_format(void) {
WpTestFuncResult test_str8_find(void) {
b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
WpStr8RO s = wapp_str8_lit("Do as I say, not as I do");
result = wapp_str8_find(&s, wapp_str8_lit_ro("d")) != -1;
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not")) != -1);
@@ -394,7 +394,7 @@ WpTestFuncResult test_str8_find(void) {
WpTestFuncResult test_str8_rfind(void) {
b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
WpStr8RO s = wapp_str8_lit("Do as I say, not as I do");
result = wapp_str8_rfind(&s, wapp_str8_lit_ro("d")) != -1;
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not")) != -1);
@@ -412,19 +412,19 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_split(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_split(&arena, &str, &delim2);
Str8RO splits1[] = {
WpStr8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
};
Str8RO splits2[] = {
WpStr8RO splits2[] = {
wapp_str8_slice(&str, 0, 12),
wapp_str8_slice(&str, 16, 19),
};
@@ -443,7 +443,7 @@ WpTestFuncResult test_str8_split(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running1) {
Str8 *node = wapp_dbl_list_get(Str8, list1, index1);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
result = result && wapp_str8_equal(node, &(splits1[index1]));
++index1;
@@ -453,7 +453,7 @@ WpTestFuncResult test_str8_split(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running2) {
Str8 *node = wapp_dbl_list_get(Str8, list2, index2);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
result = result && wapp_str8_equal(node, &(splits2[index2]));
++index2;
@@ -469,11 +469,11 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim = wapp_str8_lit(" ");
WpStr8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
WpStr8RO splits[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 19),
@@ -488,7 +488,7 @@ WpTestFuncResult test_str8_split_with_max(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running) {
Str8 *node = wapp_dbl_list_get(Str8, list, index);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
result = result && wapp_str8_equal(node, &(splits[index]));
++index;
@@ -504,19 +504,19 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8RO splits1[] = {
WpStr8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
};
Str8RO splits2[] = {
WpStr8RO splits2[] = {
wapp_str8_slice(&str, 0, 12),
wapp_str8_slice(&str, 16, 19),
};
@@ -535,7 +535,7 @@ WpTestFuncResult test_str8_rsplit(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running1) {
Str8 *node = wapp_dbl_list_get(Str8, list1, index1);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
result = result && wapp_str8_equal(node, &(splits1[index1]));
++index1;
@@ -545,7 +545,7 @@ WpTestFuncResult test_str8_rsplit(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running2) {
Str8 *node = wapp_dbl_list_get(Str8, list2, index2);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
result = result && wapp_str8_equal(node, &(splits2[index2]));
++index2;
@@ -561,11 +561,11 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim = wapp_str8_lit(" ");
WpStr8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
WpStr8RO splits[] = {
wapp_str8_slice(&str, 0, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
@@ -580,7 +580,7 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running) {
Str8 *node = wapp_dbl_list_get(Str8, list, index);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
result = result && wapp_str8_equal(node, &(splits[index]));
++index;
@@ -596,13 +596,13 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
WpStr8 *join1 = wapp_str8_join(&arena, list1, &delim1);
WpStr8 *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 @@ WpTestFuncResult test_str8_join(void) {
WpTestFuncResult test_str8_from_bytes(void) {
b8 result;
Str8 str = wapp_str8_buf(1024);
WpStr8 str = wapp_str8_buf(1024);
U8Array bytes = wapp_array(u8, 'W', 'A', 'P', 'P');
wapp_str8_from_bytes(&str, bytes);
+109 -109
View File
@@ -6,25 +6,25 @@
WpTestFuncResult test_str8_lit(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
result = s1.capacity == 22 && s1.capacity != s1.size;
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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");
WpStr8 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 wpTesterResult(result);
@@ -33,25 +33,25 @@ WpTestFuncResult test_str8_lit(void) {
WpTestFuncResult test_str8_lit_ro(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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 wpTesterResult(result);
@@ -60,16 +60,16 @@ WpTestFuncResult test_str8_lit_ro(void) {
WpTestFuncResult test_str8_buf(void) {
b8 result;
Str8 s1 = wapp_str8_buf(1024);
WpStr8 s1 = wapp_str8_buf(1024);
result = s1.capacity == 1024 && s1.size == 0;
Str8 s2 = wapp_str8_buf(2048);
WpStr8 s2 = wapp_str8_buf(2048);
result = result && s2.capacity == 2048 && s2.size == 0;
Str8 s3 = wapp_str8_buf(4096);
WpStr8 s3 = wapp_str8_buf(4096);
result = result && s3.capacity == 4096 && s3.size == 0;
Str8 s4 = wapp_str8_buf(8192);
WpStr8 s4 = wapp_str8_buf(8192);
result = result && s4.capacity == 8192 && s4.size == 0;
return wpTesterResult(result);
@@ -84,7 +84,7 @@ WpTestFuncResult test_str8_alloc_buf(void) {
u64 capacity = 4096;
Str8 *s = wapp_str8_alloc_buf(&allocator, capacity);
WpStr8 *s = wapp_str8_alloc_buf(&allocator, capacity);
if (!s) {
result = false;
wapp_mem_arena_allocator_destroy(&allocator);
@@ -112,7 +112,7 @@ WpTestFuncResult test_str8_alloc_cstr(void) {
const char *str = "Abdelrahman";
u64 length = strlen(str);
Str8 *s = wapp_str8_alloc_cstr(&allocator, str);
WpStr8 *s = wapp_str8_alloc_cstr(&allocator, str);
if (!s) {
return wpTesterResult(false);
}
@@ -131,8 +131,8 @@ WpTestFuncResult test_str8_alloc_str8(void) {
return wpTesterResult(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_str8(&allocator, &str);
WpStr8 str = wapp_str8_lit("Abdelrahman");
WpStr8 *s = wapp_str8_alloc_str8(&allocator, &str);
if (!s) {
return wpTesterResult(false);
}
@@ -151,8 +151,8 @@ WpTestFuncResult test_str8_alloc_substr(void) {
return wpTesterResult(false);
}
Str8 str = wapp_str8_lit("Abdelrahman");
Str8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
WpStr8 str = wapp_str8_lit("Abdelrahman");
WpStr8 *s = wapp_str8_alloc_substr(&allocator, &str, 3, 8);
if (!s) {
return wpTesterResult(false);
}
@@ -167,32 +167,32 @@ WpTestFuncResult test_str8_alloc_substr(void) {
WpTestFuncResult test_str8_get_index_within_bounds(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("Hello world");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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");
WpStr8RO 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 wpTesterResult(result);
}
WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
b8 result = wapp_str8_get(&s1, 20) == '\0';
return wpTesterResult(result);
}
@@ -200,31 +200,31 @@ WpTestFuncResult test_str8_get_index_out_of_bounds(void) {
WpTestFuncResult test_str8_set(void) {
b8 result;
Str8 s1 = wapp_str8_lit("Hello world");
WpStr8 s1 = wapp_str8_lit("Hello world");
wapp_str8_set(&s1, 4, 'f');
result = wapp_str8_get(&s1, 4) == 'f';
Str8 s2 = wapp_str8_lit("Different strokes for different folks");
WpStr8 s2 = wapp_str8_lit("Different strokes for different folks");
wapp_str8_set(&s2, 0, 'A');
result = result && wapp_str8_get(&s2, 0) == 'A';
Str8 s3 = wapp_str8_lit("Discretion is the better part of valour");
WpStr8 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';
Str8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
WpStr8 s4 = wapp_str8_lit("Distance lends enchantment to the view");
wapp_str8_set(&s4, 20, 'R');
result = result && wapp_str8_get(&s4, 20) == 'R';
Str8 s5 = wapp_str8_lit("Do as I say, not as I do");
WpStr8 s5 = wapp_str8_lit("Do as I say, not as I do");
wapp_str8_set(&s5, 11, '.');
result = result && wapp_str8_get(&s5, 11) == '.';
Str8 s6 = wapp_str8_lit("Do as you would be done by");
WpStr8 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';
Str8 s7 = wapp_str8_lit("Do unto others as you would have them do to you");
WpStr8 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';
@@ -234,8 +234,8 @@ WpTestFuncResult test_str8_set(void) {
WpTestFuncResult test_str8_push_back(void) {
b8 result;
Str8 expected = wapp_str8_lit("Abdelrahman");
Str8 buf = wapp_str8_buf(64);
WpStr8 expected = wapp_str8_lit("Abdelrahman");
WpStr8 buf = wapp_str8_buf(64);
wapp_str8_push_back(&buf, 'A');
wapp_str8_push_back(&buf, 'b');
wapp_str8_push_back(&buf, 'd');
@@ -256,10 +256,10 @@ WpTestFuncResult test_str8_push_back(void) {
WpTestFuncResult test_str8_equal(void) {
b8 result;
Str8RO s1 = wapp_str8_lit_ro("hello");
Str8RO s2 = wapp_str8_lit_ro("hell");
Str8RO s3 = wapp_str8_lit_ro("hello");
Str8RO s4 = wapp_str8_lit_ro("goodbye");
WpStr8RO s1 = wapp_str8_lit_ro("hello");
WpStr8RO s2 = wapp_str8_lit_ro("hell");
WpStr8RO s3 = wapp_str8_lit_ro("hello");
WpStr8RO s4 = wapp_str8_lit_ro("goodbye");
result = wapp_str8_equal(&s1, &s2) == false;
result = result && wapp_str8_equal(&s1, &s3) == (b8)true;
@@ -270,18 +270,18 @@ WpTestFuncResult test_str8_equal(void) {
WpTestFuncResult test_str8_slice(void) {
b8 result;
Str8 s = wapp_str8_lit("Different strokes for different folks");
WpStr8 s = wapp_str8_lit("Different strokes for different folks");
Str8RO sub1 = wapp_str8_slice(&s, 3, 9);
WpStr8RO sub1 = wapp_str8_slice(&s, 3, 9);
result = sub1.size == 6 && sub1.capacity == 6;
Str8RO sub2 = wapp_str8_slice(&s, 18, 21);
WpStr8RO sub2 = wapp_str8_slice(&s, 18, 21);
result = result && sub2.size == 3 && sub2.capacity == 3;
Str8RO sub3 = wapp_str8_slice(&s, 5, 1);
WpStr8RO sub3 = wapp_str8_slice(&s, 5, 1);
result = result && sub3.size == 0 && sub3.capacity == 0;
Str8RO sub4 = wapp_str8_slice(&s, 70, 80);
WpStr8RO sub4 = wapp_str8_slice(&s, 70, 80);
result = result && sub4.size == 0 && sub4.capacity == 0;
return wpTesterResult(result);
@@ -291,13 +291,13 @@ WpTestFuncResult 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.");
WpStr8 str = wapp_str8_lit("Hello world");
WpStr8 suffix1 = wapp_str8_lit(" from me.");
WpStr8 suffix2 = wapp_str8_lit(" This is my code.");
WpStr8 concat1 = wapp_str8_lit("Hello world from me.");
WpStr8 concat2 = wapp_str8_lit("Hello world from me. This is my code.");
Str8 *output;
WpStr8 *output;
output = wapp_str8_alloc_concat(&arena, &str, &suffix1);
result = output->size == concat1.size && wapp_str8_equal(output, &concat1);
@@ -313,11 +313,11 @@ WpTestFuncResult test_str8_alloc_concat(void) {
WpTestFuncResult 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");
WpStr8 str = wapp_str8_lit("Hello world");
WpStr8 suffix1 = wapp_str8_lit(" from me.");
WpStr8 suffix2 = wapp_str8_lit(" This is my code.");
WpStr8 concat1 = wapp_str8_lit("Hello world from me.");
WpStr8 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 @@ WpTestFuncResult test_str8_concat_capped(void) {
WpTestFuncResult test_str8_copy_cstr_capped(void) {
b8 result;
Str8 buf = wapp_str8_buf(32);
WpStr8 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");
WpStr8RO src1_cp = wapp_str8_lit_ro("Hello world");
WpStr8RO 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 @@ WpTestFuncResult test_str8_copy_cstr_capped(void) {
WpTestFuncResult 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");
WpStr8 buf = wapp_str8_buf(32);
WpStr8RO src1 = wapp_str8_lit_ro("Hello world");
WpStr8RO src2 = wapp_str8_lit_ro("Hello world from the Wizard Apprentice standard library");
WpStr8RO 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 @@ WpTestFuncResult test_str8_copy_str8_capped(void) {
WpTestFuncResult 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");
WpStr8 buf = wapp_str8_buf(128);
WpStr8 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);
@@ -378,7 +378,7 @@ WpTestFuncResult test_str8_format(void) {
WpTestFuncResult test_str8_find(void) {
b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
WpStr8RO s = wapp_str8_lit("Do as I say, not as I do");
result = wapp_str8_find(&s, wapp_str8_lit_ro("d")) != -1;
result = result && (wapp_str8_find(&s, wapp_str8_lit_ro("not")) != -1);
@@ -394,7 +394,7 @@ WpTestFuncResult test_str8_find(void) {
WpTestFuncResult test_str8_rfind(void) {
b8 result;
Str8RO s = wapp_str8_lit("Do as I say, not as I do");
WpStr8RO s = wapp_str8_lit("Do as I say, not as I do");
result = wapp_str8_rfind(&s, wapp_str8_lit_ro("d")) != -1;
result = result && (wapp_str8_rfind(&s, wapp_str8_lit_ro("not")) != -1);
@@ -412,19 +412,19 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_split(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_split(&arena, &str, &delim2);
Str8RO splits1[] = {
WpStr8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
};
Str8RO splits2[] = {
WpStr8RO splits2[] = {
wapp_str8_slice(&str, 0, 12),
wapp_str8_slice(&str, 16, 19),
};
@@ -443,7 +443,7 @@ WpTestFuncResult test_str8_split(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running1) {
Str8 *node = wapp_dbl_list_get(Str8, list1, index1);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
result = result && wapp_str8_equal(node, &(splits1[index1]));
++index1;
@@ -453,7 +453,7 @@ WpTestFuncResult test_str8_split(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running2) {
Str8 *node = wapp_dbl_list_get(Str8, list2, index2);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
result = result && wapp_str8_equal(node, &(splits2[index2]));
++index2;
@@ -469,11 +469,11 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim = wapp_str8_lit(" ");
WpStr8List *list = wapp_str8_split_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
WpStr8RO splits[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 19),
@@ -488,7 +488,7 @@ WpTestFuncResult test_str8_split_with_max(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running) {
Str8 *node = wapp_dbl_list_get(Str8, list, index);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
result = result && wapp_str8_equal(node, &(splits[index]));
++index;
@@ -504,19 +504,19 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
Str8RO splits1[] = {
WpStr8RO splits1[] = {
wapp_str8_slice(&str, 0, 5),
wapp_str8_slice(&str, 6, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
};
Str8RO splits2[] = {
WpStr8RO splits2[] = {
wapp_str8_slice(&str, 0, 12),
wapp_str8_slice(&str, 16, 19),
};
@@ -535,7 +535,7 @@ WpTestFuncResult test_str8_rsplit(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running1) {
Str8 *node = wapp_dbl_list_get(Str8, list1, index1);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list1, index1);
result = result && wapp_str8_equal(node, &(splits1[index1]));
++index1;
@@ -545,7 +545,7 @@ WpTestFuncResult test_str8_rsplit(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running2) {
Str8 *node = wapp_dbl_list_get(Str8, list2, index2);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list2, index2);
result = result && wapp_str8_equal(node, &(splits2[index2]));
++index2;
@@ -561,11 +561,11 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim = wapp_str8_lit(" ");
WpStr8List *list = wapp_str8_rsplit_with_max(&arena, &str, &delim, 2);
Str8RO splits[] = {
WpStr8RO splits[] = {
wapp_str8_slice(&str, 0, 11),
wapp_str8_slice(&str, 12, 16),
wapp_str8_slice(&str, 17, 19),
@@ -580,7 +580,7 @@ WpTestFuncResult test_str8_rsplit_with_max(void) {
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
// MSVC Spectre mitigation warnings
while (running) {
Str8 *node = wapp_dbl_list_get(Str8, list, index);
WpStr8 *node = wapp_dbl_list_get(WpStr8, list, index);
result = result && wapp_str8_equal(node, &(splits[index]));
++index;
@@ -596,13 +596,13 @@ WpTestFuncResult 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);
WpStr8 str = wapp_str8_lit("hello world from me");
WpStr8 delim1 = wapp_str8_lit(" ");
WpStr8 delim2 = wapp_str8_lit("from");
WpStr8List *list1 = wapp_str8_rsplit(&arena, &str, &delim1);
WpStr8List *list2 = wapp_str8_rsplit(&arena, &str, &delim2);
WpStr8 *join1 = wapp_str8_join(&arena, list1, &delim1);
WpStr8 *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,8 +615,8 @@ WpTestFuncResult test_str8_join(void) {
WpTestFuncResult test_str8_from_bytes(void) {
b8 result;
Str8 str = wapp_str8_buf(1024);
Str8 expected = wapp_str8_lit_ro("WAPP");
WpStr8 str = wapp_str8_buf(1024);
WpStr8 expected = wapp_str8_lit_ro("WAPP");
U8Array bytes = wapp_array(u8, 'W', 'A', 'P', 'P');
wapp_str8_from_bytes(&str, bytes);
+102 -102
View File
@@ -4,33 +4,33 @@
WpTestFuncResult test_str8_list_get(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_get(Str8, &list, 0);
WpStr8 *node = wapp_dbl_list_get(WpStr8, &list, 0);
result = node == &s1 && wapp_str8_equal(node, &s1);
node = wapp_dbl_list_get(Str8, &list, 1);
node = wapp_dbl_list_get(WpStr8, &list, 1);
result = result && node == &s2 && wapp_str8_equal(node, &s2);
node = wapp_dbl_list_get(Str8, &list, 2);
node = wapp_dbl_list_get(WpStr8, &list, 2);
result = result && node == &s3 && wapp_str8_equal(node, &s3);
node = wapp_dbl_list_get(Str8, &list, 3);
node = wapp_dbl_list_get(WpStr8, &list, 3);
result = result && node == &s4 && wapp_str8_equal(node, &s4);
node = wapp_dbl_list_get(Str8, &list, 4);
node = wapp_dbl_list_get(WpStr8, &list, 4);
result = result && node == &s5 && wapp_str8_equal(node, &s5);
return wpTesterResult(result);
@@ -39,19 +39,19 @@ WpTestFuncResult test_str8_list_get(void) {
WpTestFuncResult test_str8_list_push_front(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_front(Str8, &list, &s1);
wapp_dbl_list_push_front(WpStr8, &list, &s1);
result = list.first == list.last && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_front(Str8, &list, &s2);
wapp_dbl_list_push_front(WpStr8, &list, &s2);
result = result && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_front(Str8, &list, &s3);
wapp_dbl_list_push_front(WpStr8, &list, &s3);
result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wpTesterResult(result);
@@ -60,19 +60,19 @@ WpTestFuncResult test_str8_list_push_front(void) {
WpTestFuncResult test_str8_list_push_back(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
result = list.first == list.last && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
result = result && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wpTesterResult(result);
@@ -81,28 +81,28 @@ WpTestFuncResult test_str8_list_push_back(void) {
WpTestFuncResult test_str8_list_insert(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
Str8 s6 = wapp_str8_lit("6");
Str8 s7 = wapp_str8_lit("7");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
WpStr8 s6 = wapp_str8_lit("6");
WpStr8 s7 = wapp_str8_lit("7");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node;
wapp_dbl_list_insert(Str8, &list, &s6, 2);
node = wapp_dbl_list_get(Str8, &list, 2);
WpStr8 *node;
wapp_dbl_list_insert(WpStr8, &list, &s6, 2);
node = wapp_dbl_list_get(WpStr8, &list, 2);
result = node != NULL && node == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6;
wapp_dbl_list_insert(Str8, &list, &s7, 5);
node = wapp_dbl_list_get(Str8, &list, 5);
wapp_dbl_list_insert(WpStr8, &list, &s7, 5);
node = wapp_dbl_list_get(WpStr8, &list, 5);
result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wpTesterResult(result);
@@ -111,33 +111,33 @@ WpTestFuncResult test_str8_list_insert(void) {
WpTestFuncResult test_str8_list_pop_front(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_pop_front(Str8, &list);
WpStr8 *node = wapp_dbl_list_pop_front(WpStr8, &list);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -146,33 +146,33 @@ WpTestFuncResult test_str8_list_pop_front(void) {
WpTestFuncResult test_str8_list_pop_back(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_front(Str8, &list, &s1);
wapp_dbl_list_push_front(Str8, &list, &s2);
wapp_dbl_list_push_front(Str8, &list, &s3);
wapp_dbl_list_push_front(Str8, &list, &s4);
wapp_dbl_list_push_front(Str8, &list, &s5);
wapp_dbl_list_push_front(WpStr8, &list, &s1);
wapp_dbl_list_push_front(WpStr8, &list, &s2);
wapp_dbl_list_push_front(WpStr8, &list, &s3);
wapp_dbl_list_push_front(WpStr8, &list, &s4);
wapp_dbl_list_push_front(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_pop_back(Str8, &list);
WpStr8 *node = wapp_dbl_list_pop_back(WpStr8, &list);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -181,33 +181,33 @@ WpTestFuncResult test_str8_list_pop_back(void) {
WpTestFuncResult test_str8_list_remove(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_remove(Str8, &list, 0);
WpStr8 *node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -216,13 +216,13 @@ WpTestFuncResult test_str8_list_remove(void) {
WpTestFuncResult test_str8_list_empty(void) {
b8 result;
Str8List list = wapp_dbl_list(Str8);
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_lit("Hello"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_lit("from"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_lit("wizapp"));
wapp_dbl_list_push_back(Str8, &list, &wapp_str8_lit("stdlib"));
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(WpStr8, &list, &wapp_str8_lit("Hello"));
wapp_dbl_list_push_back(WpStr8, &list, &wapp_str8_lit("from"));
wapp_dbl_list_push_back(WpStr8, &list, &wapp_str8_lit("wizapp"));
wapp_dbl_list_push_back(WpStr8, &list, &wapp_str8_lit("stdlib"));
wapp_dbl_list_empty(Str8, &list);
wapp_dbl_list_empty(WpStr8, &list);
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;
+106 -106
View File
@@ -4,33 +4,33 @@
WpTestFuncResult test_str8_list_get(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_get(Str8, &list, 0);
WpStr8 *node = wapp_dbl_list_get(WpStr8, &list, 0);
result = node == &s1 && wapp_str8_equal(node, &s1);
node = wapp_dbl_list_get(Str8, &list, 1);
node = wapp_dbl_list_get(WpStr8, &list, 1);
result = result && node == &s2 && wapp_str8_equal(node, &s2);
node = wapp_dbl_list_get(Str8, &list, 2);
node = wapp_dbl_list_get(WpStr8, &list, 2);
result = result && node == &s3 && wapp_str8_equal(node, &s3);
node = wapp_dbl_list_get(Str8, &list, 3);
node = wapp_dbl_list_get(WpStr8, &list, 3);
result = result && node == &s4 && wapp_str8_equal(node, &s4);
node = wapp_dbl_list_get(Str8, &list, 4);
node = wapp_dbl_list_get(WpStr8, &list, 4);
result = result && node == &s5 && wapp_str8_equal(node, &s5);
return wpTesterResult(result);
@@ -39,19 +39,19 @@ WpTestFuncResult test_str8_list_get(void) {
WpTestFuncResult test_str8_list_push_front(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_front(Str8, &list, &s1);
wapp_dbl_list_push_front(WpStr8, &list, &s1);
result = list.first == list.last && list.first->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_front(Str8, &list, &s2);
wapp_dbl_list_push_front(WpStr8, &list, &s2);
result = result && list.first->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_front(Str8, &list, &s3);
wapp_dbl_list_push_front(WpStr8, &list, &s3);
result = result && list.first->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wpTesterResult(result);
@@ -60,19 +60,19 @@ WpTestFuncResult test_str8_list_push_front(void) {
WpTestFuncResult test_str8_list_push_back(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
result = list.first == list.last && list.last->item == &s1 && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
result = result && list.last->item == &s2 && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
result = result && list.last->item == &s3 && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
return wpTesterResult(result);
@@ -81,28 +81,28 @@ WpTestFuncResult test_str8_list_push_back(void) {
WpTestFuncResult test_str8_list_insert(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
Str8 s6 = wapp_str8_lit("6");
Str8 s7 = wapp_str8_lit("7");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
WpStr8 s6 = wapp_str8_lit("6");
WpStr8 s7 = wapp_str8_lit("7");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node;
wapp_dbl_list_insert(Str8, &list, &s6, 2);
node = wapp_dbl_list_get(Str8, &list, 2);
WpStr8 *node;
wapp_dbl_list_insert(WpStr8, &list, &s6, 2);
node = wapp_dbl_list_get(WpStr8, &list, 2);
result = node != NULL && node == &s6 && wapp_str8_list_total_size(&list) == 6 && list.node_count == 6;
wapp_dbl_list_insert(Str8, &list, &s7, 5);
node = wapp_dbl_list_get(Str8, &list, 5);
wapp_dbl_list_insert(WpStr8, &list, &s7, 5);
node = wapp_dbl_list_get(WpStr8, &list, 5);
result = result && node != NULL && node == &s7 && wapp_str8_list_total_size(&list) == 7 && list.node_count == 7;
return wpTesterResult(result);
@@ -111,33 +111,33 @@ WpTestFuncResult test_str8_list_insert(void) {
WpTestFuncResult test_str8_list_pop_front(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_pop_front(Str8, &list);
WpStr8 *node = wapp_dbl_list_pop_front(WpStr8, &list);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_front(Str8, &list);
node = wapp_dbl_list_pop_front(WpStr8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -146,33 +146,33 @@ WpTestFuncResult test_str8_list_pop_front(void) {
WpTestFuncResult test_str8_list_pop_back(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_front(Str8, &list, &s1);
wapp_dbl_list_push_front(Str8, &list, &s2);
wapp_dbl_list_push_front(Str8, &list, &s3);
wapp_dbl_list_push_front(Str8, &list, &s4);
wapp_dbl_list_push_front(Str8, &list, &s5);
wapp_dbl_list_push_front(WpStr8, &list, &s1);
wapp_dbl_list_push_front(WpStr8, &list, &s2);
wapp_dbl_list_push_front(WpStr8, &list, &s3);
wapp_dbl_list_push_front(WpStr8, &list, &s4);
wapp_dbl_list_push_front(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_pop_back(Str8, &list);
WpStr8 *node = wapp_dbl_list_pop_back(WpStr8, &list);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_pop_back(Str8, &list);
node = wapp_dbl_list_pop_back(WpStr8, &list);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -181,33 +181,33 @@ WpTestFuncResult test_str8_list_pop_back(void) {
WpTestFuncResult test_str8_list_remove(void) {
b8 result;
Str8 s1 = wapp_str8_lit("1");
Str8 s2 = wapp_str8_lit("2");
Str8 s3 = wapp_str8_lit("3");
Str8 s4 = wapp_str8_lit("4");
Str8 s5 = wapp_str8_lit("5");
WpStr8 s1 = wapp_str8_lit("1");
WpStr8 s2 = wapp_str8_lit("2");
WpStr8 s3 = wapp_str8_lit("3");
WpStr8 s4 = wapp_str8_lit("4");
WpStr8 s5 = wapp_str8_lit("5");
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
wapp_dbl_list_push_back(Str8, &list, &s1);
wapp_dbl_list_push_back(Str8, &list, &s2);
wapp_dbl_list_push_back(Str8, &list, &s3);
wapp_dbl_list_push_back(Str8, &list, &s4);
wapp_dbl_list_push_back(Str8, &list, &s5);
wapp_dbl_list_push_back(WpStr8, &list, &s1);
wapp_dbl_list_push_back(WpStr8, &list, &s2);
wapp_dbl_list_push_back(WpStr8, &list, &s3);
wapp_dbl_list_push_back(WpStr8, &list, &s4);
wapp_dbl_list_push_back(WpStr8, &list, &s5);
Str8 *node = wapp_dbl_list_remove(Str8, &list, 0);
WpStr8 *node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = node == &s1 && wapp_str8_equal(node, &s1) && wapp_str8_list_total_size(&list) == 4 && list.node_count == 4;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s2 && wapp_str8_equal(node, &s2) && wapp_str8_list_total_size(&list) == 3 && list.node_count == 3;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s3 && wapp_str8_equal(node, &s3) && wapp_str8_list_total_size(&list) == 2 && list.node_count == 2;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s4 && wapp_str8_equal(node, &s4) && wapp_str8_list_total_size(&list) == 1 && list.node_count == 1;
node = wapp_dbl_list_remove(Str8, &list, 0);
node = wapp_dbl_list_remove(WpStr8, &list, 0);
result = result && node == &s5 && wapp_str8_equal(node, &s5) && wapp_str8_list_total_size(&list) == 0 && list.node_count == 0;
return wpTesterResult(result);
@@ -216,21 +216,21 @@ WpTestFuncResult test_str8_list_remove(void) {
WpTestFuncResult test_str8_list_empty(void) {
b8 result;
Str8List list = wapp_dbl_list(Str8);
WpStr8List list = wapp_dbl_list(WpStr8);
Str8 hello = wapp_str8_lit("Hello");
wapp_dbl_list_push_back(Str8, &list, &hello);
WpStr8 hello = wapp_str8_lit("Hello");
wapp_dbl_list_push_back(WpStr8, &list, &hello);
Str8 from = wapp_str8_lit("from");
wapp_dbl_list_push_back(Str8, &list, &from);
WpStr8 from = wapp_str8_lit("from");
wapp_dbl_list_push_back(WpStr8, &list, &from);
Str8 wizapp = wapp_str8_lit("wizapp");
wapp_dbl_list_push_back(Str8, &list, &wizapp);
WpStr8 wizapp = wapp_str8_lit("wizapp");
wapp_dbl_list_push_back(WpStr8, &list, &wizapp);
Str8 stdlib = wapp_str8_lit("stdlib");
wapp_dbl_list_push_back(Str8, &list, &stdlib);
WpStr8 stdlib = wapp_str8_lit("stdlib");
wapp_dbl_list_push_back(WpStr8, &list, &stdlib);
wapp_dbl_list_empty(Str8, &list);
wapp_dbl_list_empty(WpStr8, &list);
result = list.first == NULL && list.last == NULL && list.node_count == 0 && wapp_str8_list_total_size(&list) == 0;