summaryrefslogtreecommitdiff
path: root/strings/test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'strings/test.cpp')
-rw-r--r--strings/test.cpp65
1 files changed, 0 insertions, 65 deletions
diff --git a/strings/test.cpp b/strings/test.cpp
deleted file mode 100644
index 49f81c9..0000000
--- a/strings/test.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-#include <stdio.h>
-#include "strings.h"
-#include "strings.cpp"
-
-void TestCstrSize()
-{
- u64 size = CstrSize("hello sailor\n");
- assert(size == 13 && "test_cstr_size() failed"
- "the cstr size was wrong\n");
-}
-
-void TestEmptyCstrSize()
-{
- u64 size = CstrSize("");
- assert(size == 0 && "test_empty_cstr_size() failed"
- "the cstr size was wrong\n");
-}
-
-void TestStr8InitCstr(u8* buffer, u64 buffer_size)
-{
- struct arena a = {};
- arena_init(&a, buffer, buffer_size);
- struct res_str8 qres = Str8InitCstr(&a, "hello sailor");
- assert((qres.bytes_count == 12) && "Error TestStr8InitCstr:\n"
- "Reason: Invalid size of allocated string\n"
- "Hint: check what is happening to the bytes_count and how it is set first\n");
-}
-
-void TestStr8InitCstrEmpty(u8* buffer, u64 buffer_size)
-{
- struct arena a = {};
- arena_init(&a, buffer, buffer_size);
- struct res_str8 qres = Str8InitCstr(&a, "");
- assert((qres.string.size == 0) && "Error TestStr8InitCstrEmpty:\n"
- "Reason: Invalid size of allocated string\n"
- "Hint: check what is happening to the bytes_count and how it is set first\n");
-}
-
-void TestStr8InitCstrNoSpace(u8* buffer, u8 buffer_size)
-{
- struct arena a = {};
- arena_init(&a, buffer, buffer_size);
- struct res_str8 qres = Str8InitCstr(&a, "hello sailor, looks like you've got no space here on this boat!");
- assert(qres.string.size == 0 && "Error TestStr8InitStrNoSpace:\n"
- "Reason: the bytes count is not 0, even though the string is larger than the supposedly available\n"
- "arena space. This is an error and should not occur.\n"
- "Hint: Look at what is going on in the allocation since that arena helpers handle allocations\n.");
-}
-
-void test_strings()
-{
- printf("\n======= Testing Strings Library =======\n");
- printf("===== Testing Cstring Functions =====\n");
- TestCstrSize();
- TestEmptyCstrSize();
-
- u64 buffer_size = KB(64);
- u8* buffer = (u8*)malloc(sizeof(u8)*buffer_size);
-
- TestStr8InitCstr(buffer, buffer_size);
- TestStr8InitCstrEmpty(buffer, buffer_size);
- TestStr8InitCstrNoSpace(buffer, 8);
- printf("Cstring tests passed successfully\n");
- free(buffer);
-}