Switch to using b32
This commit is contained in:
@@ -2,20 +2,19 @@
|
||||
#include "wapp.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAIN_BUF_SIZE 4096
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
bool result;
|
||||
b32 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);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
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 = {0};
|
||||
wapp_str8_list_push_back(&parts, &wapp_str8_node_from_str8(tmp));
|
||||
@@ -28,7 +27,7 @@ TestFuncResult test_cpath_join_path(void) {
|
||||
|
||||
wapp_str8_list_pop_front(&parts);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
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);
|
||||
@@ -37,27 +36,27 @@ TestFuncResult test_cpath_join_path(void) {
|
||||
wapp_str8_list_pop_front(&parts);
|
||||
wapp_str8_list_push_front(&parts, &wapp_str8_node_from_str8(tmp));
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
|
||||
wapp_str8_format(&tmp, "home%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
|
||||
wapp_str8_list_pop_front(&parts);
|
||||
wapp_str8_list_push_front(&parts, &wapp_str8_node_from_cstr("home"));
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
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_str8_list_empty(&parts);
|
||||
|
||||
wapp_str8_format(&tmp, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
|
||||
wapp_str8_list_push_back(&parts, &wapp_str8_node_from_str8(tmp));
|
||||
wapp_str8_list_push_back(&parts, &wapp_str8_node_from_cstr(""));
|
||||
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
@@ -87,15 +86,15 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = output != NULL && wapp_str8_equal(output, &expected);
|
||||
@@ -111,15 +110,15 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%ctest", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
@@ -135,42 +134,42 @@ TestFuncResult test_cpath_dirup(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8 *output = NULL;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, ".");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != NULL && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
|
@@ -2,20 +2,19 @@
|
||||
#include "wapp.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define MAIN_BUF_SIZE 4096
|
||||
#define TMP_BUF_SIZE 1024
|
||||
|
||||
TestFuncResult test_cpath_join_path(void) {
|
||||
bool result;
|
||||
b32 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);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
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 = {};
|
||||
|
||||
@@ -36,7 +35,7 @@ TestFuncResult test_cpath_join_path(void) {
|
||||
|
||||
wapp_str8_list_pop_front(&parts);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
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);
|
||||
@@ -48,25 +47,25 @@ TestFuncResult test_cpath_join_path(void) {
|
||||
Str8Node tmp_node_2 = wapp_str8_node_from_str8(tmp);
|
||||
wapp_str8_list_push_front(&parts, &tmp_node_2);
|
||||
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
|
||||
wapp_str8_format(&tmp, "home%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%c", WAPP_PATH_SEP);
|
||||
wapp_str8_list_pop_front(&parts);
|
||||
|
||||
Str8Node home_node_2 = wapp_str8_node_from_cstr("home");
|
||||
wapp_str8_list_push_front(&parts, &home_node_2);
|
||||
|
||||
wapp_str8_format(&expected, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
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_str8_list_empty(&parts);
|
||||
|
||||
wapp_str8_format(&tmp, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
Str8Node tmp_node_3 = wapp_str8_node_from_str8(tmp);
|
||||
wapp_str8_list_push_back(&parts, &tmp_node_3);
|
||||
@@ -74,7 +73,7 @@ TestFuncResult test_cpath_join_path(void) {
|
||||
Str8Node empty_node = wapp_str8_node_from_cstr("");
|
||||
wapp_str8_list_push_back(&parts, &empty_node);
|
||||
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
wapp_cpath_join_path(&out, &parts);
|
||||
result = result && wapp_str8_equal(&out, &expected);
|
||||
@@ -108,15 +107,15 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = output != nullptr && wapp_str8_equal(output, &expected);
|
||||
@@ -134,15 +133,15 @@ TestFuncResult test_cpath_dirname(void) {
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%ctest", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%ctest", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%ctest%c", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirname(&arena, &tmp);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
@@ -158,42 +157,42 @@ TestFuncResult test_cpath_dirup(void) {
|
||||
return wapp_tester_result(false);
|
||||
}
|
||||
|
||||
bool result;
|
||||
b32 result;
|
||||
Str8 *output = nullptr;
|
||||
|
||||
Str8 expected = wapp_str8_buf(MAIN_BUF_SIZE);
|
||||
Str8 tmp = wapp_str8_buf(TMP_BUF_SIZE);
|
||||
|
||||
// CASE 1
|
||||
wapp_str8_format(&tmp, "%c", PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%c", WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 2
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%c", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 3
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, ".");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 3);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 4
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", PATH_SEP);
|
||||
wapp_str8_format(&tmp, "%chome%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_format(&expected, "%chome", WAPP_PATH_SEP);
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
result = result && output != nullptr && wapp_str8_equal(output, &expected);
|
||||
|
||||
// CASE 5
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_str8_format(&tmp, "home%cabdelrahman%cDocuments", WAPP_PATH_SEP, WAPP_PATH_SEP);
|
||||
wapp_str8_copy_cstr_capped(&expected, "home");
|
||||
|
||||
output = wapp_cpath_dirup(&arena, &tmp, 2);
|
||||
|
Reference in New Issue
Block a user