Fix cpath tests on Windows
This commit is contained in:
parent
ce656a6275
commit
17f0f0eaf3
@ -81,87 +81,99 @@ TEST_JOIN_PATH_EXIT:
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirname(void) {
|
||||
char buf[4096] = {0};
|
||||
char tmp[4096] = {0};
|
||||
char dst[4096] = {0};
|
||||
char expected[4096] = {0};
|
||||
char tmp[1024] = {0};
|
||||
|
||||
wapp_cpath_dirname(buf, "/");
|
||||
bool result = strcmp(buf, "/") == 0;
|
||||
sprintf(tmp, "%c", PATH_SEP);
|
||||
wapp_cpath_dirname(dst, tmp);
|
||||
bool result = strcmp(dst, tmp) == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRNAME_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
wapp_cpath_dirname(buf, "home");
|
||||
result = strcmp(buf, ".") == 0;
|
||||
memset(dst, 0, strlen(dst));
|
||||
wapp_cpath_dirname(dst, "home");
|
||||
result = strcmp(dst, ".") == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRNAME_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
wapp_cpath_dirname(buf, "");
|
||||
result = strcmp(buf, ".") == 0;
|
||||
memset(dst, 0, strlen(dst));
|
||||
wapp_cpath_dirname(dst, "");
|
||||
result = strcmp(dst, ".") == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRNAME_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
sprintf(tmp, "%chome%ctest", PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirname(buf, tmp);
|
||||
result = strcmp(buf, "/home") == 0;
|
||||
sprintf(expected, "%chome", PATH_SEP);
|
||||
wapp_cpath_dirname(dst, tmp);
|
||||
result = strcmp(dst, expected) == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRNAME_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
memset(tmp, 0, strlen(tmp));
|
||||
memset(expected, 0, strlen(expected));
|
||||
sprintf(tmp, "%chome%ctest%c", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirname(buf, tmp);
|
||||
result = strcmp(buf, "/home") == 0;
|
||||
sprintf(expected, "%chome", PATH_SEP);
|
||||
wapp_cpath_dirname(dst, tmp);
|
||||
result = strcmp(dst, expected) == 0;
|
||||
|
||||
TEST_DIRNAME_EXIT:
|
||||
return wapp_tester_result(result);
|
||||
}
|
||||
|
||||
TestFuncResult test_cpath_dirup(void) {
|
||||
char buf[4096] = {0};
|
||||
char tmp[4096] = {0};
|
||||
char dst[4096] = {0};
|
||||
char expected[4096] = {0};
|
||||
char tmp[1024] = {0};
|
||||
|
||||
wapp_cpath_dirup(buf, 3, "/");
|
||||
bool result = strcmp(buf, "/") == 0;
|
||||
sprintf(tmp, "%c", PATH_SEP);
|
||||
wapp_cpath_dirup(dst, 3, tmp);
|
||||
bool result = strcmp(dst, tmp) == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRUP_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
memset(tmp, 0, strlen(tmp));
|
||||
sprintf(tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirup(buf, 3, tmp);
|
||||
result = strcmp(buf, "/") == 0;
|
||||
sprintf(expected, "%c", PATH_SEP);
|
||||
wapp_cpath_dirup(dst, 3, tmp);
|
||||
result = strcmp(dst, expected) == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRUP_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
memset(tmp, 0, strlen(tmp));
|
||||
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirup(buf, 3, tmp);
|
||||
result = strcmp(buf, ".") == 0;
|
||||
wapp_cpath_dirup(dst, 3, tmp);
|
||||
result = strcmp(dst, ".") == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRUP_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
memset(tmp, 0, strlen(tmp));
|
||||
memset(expected, 0, strlen(expected));
|
||||
sprintf(tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirup(buf, 2, tmp);
|
||||
result = strcmp(buf, "/home") == 0;
|
||||
sprintf(expected, "%chome", PATH_SEP);
|
||||
wapp_cpath_dirup(dst, 2, tmp);
|
||||
result = strcmp(dst, expected) == 0;
|
||||
if (!result) {
|
||||
goto TEST_DIRUP_EXIT;
|
||||
}
|
||||
|
||||
memset(buf, 0, strlen(buf));
|
||||
memset(dst, 0, strlen(dst));
|
||||
memset(tmp, 0, strlen(tmp));
|
||||
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||
wapp_cpath_dirup(buf, 2, tmp);
|
||||
result = strcmp(buf, "home") == 0;
|
||||
wapp_cpath_dirup(dst, 2, tmp);
|
||||
result = strcmp(dst, "home") == 0;
|
||||
|
||||
TEST_DIRUP_EXIT:
|
||||
return wapp_tester_result(result);
|
||||
|
Loading…
Reference in New Issue
Block a user