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) {
|
TestFuncResult test_cpath_dirname(void) {
|
||||||
char buf[4096] = {0};
|
char dst[4096] = {0};
|
||||||
char tmp[4096] = {0};
|
char expected[4096] = {0};
|
||||||
|
char tmp[1024] = {0};
|
||||||
|
|
||||||
wapp_cpath_dirname(buf, "/");
|
sprintf(tmp, "%c", PATH_SEP);
|
||||||
bool result = strcmp(buf, "/") == 0;
|
wapp_cpath_dirname(dst, tmp);
|
||||||
|
bool result = strcmp(dst, tmp) == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRNAME_EXIT;
|
goto TEST_DIRNAME_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
wapp_cpath_dirname(buf, "home");
|
wapp_cpath_dirname(dst, "home");
|
||||||
result = strcmp(buf, ".") == 0;
|
result = strcmp(dst, ".") == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRNAME_EXIT;
|
goto TEST_DIRNAME_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
wapp_cpath_dirname(buf, "");
|
wapp_cpath_dirname(dst, "");
|
||||||
result = strcmp(buf, ".") == 0;
|
result = strcmp(dst, ".") == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRNAME_EXIT;
|
goto TEST_DIRNAME_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
sprintf(tmp, "%chome%ctest", PATH_SEP, PATH_SEP);
|
sprintf(tmp, "%chome%ctest", PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirname(buf, tmp);
|
sprintf(expected, "%chome", PATH_SEP);
|
||||||
result = strcmp(buf, "/home") == 0;
|
wapp_cpath_dirname(dst, tmp);
|
||||||
|
result = strcmp(dst, expected) == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRNAME_EXIT;
|
goto TEST_DIRNAME_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
memset(tmp, 0, strlen(tmp));
|
memset(tmp, 0, strlen(tmp));
|
||||||
|
memset(expected, 0, strlen(expected));
|
||||||
sprintf(tmp, "%chome%ctest%c", PATH_SEP, PATH_SEP, PATH_SEP);
|
sprintf(tmp, "%chome%ctest%c", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirname(buf, tmp);
|
sprintf(expected, "%chome", PATH_SEP);
|
||||||
result = strcmp(buf, "/home") == 0;
|
wapp_cpath_dirname(dst, tmp);
|
||||||
|
result = strcmp(dst, expected) == 0;
|
||||||
|
|
||||||
TEST_DIRNAME_EXIT:
|
TEST_DIRNAME_EXIT:
|
||||||
return wapp_tester_result(result);
|
return wapp_tester_result(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestFuncResult test_cpath_dirup(void) {
|
TestFuncResult test_cpath_dirup(void) {
|
||||||
char buf[4096] = {0};
|
char dst[4096] = {0};
|
||||||
char tmp[4096] = {0};
|
char expected[4096] = {0};
|
||||||
|
char tmp[1024] = {0};
|
||||||
|
|
||||||
wapp_cpath_dirup(buf, 3, "/");
|
sprintf(tmp, "%c", PATH_SEP);
|
||||||
bool result = strcmp(buf, "/") == 0;
|
wapp_cpath_dirup(dst, 3, tmp);
|
||||||
|
bool result = strcmp(dst, tmp) == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRUP_EXIT;
|
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);
|
sprintf(tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirup(buf, 3, tmp);
|
sprintf(expected, "%c", PATH_SEP);
|
||||||
result = strcmp(buf, "/") == 0;
|
wapp_cpath_dirup(dst, 3, tmp);
|
||||||
|
result = strcmp(dst, expected) == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRUP_EXIT;
|
goto TEST_DIRUP_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
memset(tmp, 0, strlen(tmp));
|
memset(tmp, 0, strlen(tmp));
|
||||||
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirup(buf, 3, tmp);
|
wapp_cpath_dirup(dst, 3, tmp);
|
||||||
result = strcmp(buf, ".") == 0;
|
result = strcmp(dst, ".") == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRUP_EXIT;
|
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);
|
sprintf(tmp, "%chome%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirup(buf, 2, tmp);
|
sprintf(expected, "%chome", PATH_SEP);
|
||||||
result = strcmp(buf, "/home") == 0;
|
wapp_cpath_dirup(dst, 2, tmp);
|
||||||
|
result = strcmp(dst, expected) == 0;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
goto TEST_DIRUP_EXIT;
|
goto TEST_DIRUP_EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(buf, 0, strlen(buf));
|
memset(dst, 0, strlen(dst));
|
||||||
memset(tmp, 0, strlen(tmp));
|
memset(tmp, 0, strlen(tmp));
|
||||||
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
sprintf(tmp, "home%cabdelrahman%cDocuments", PATH_SEP, PATH_SEP);
|
||||||
wapp_cpath_dirup(buf, 2, tmp);
|
wapp_cpath_dirup(dst, 2, tmp);
|
||||||
result = strcmp(buf, "home") == 0;
|
result = strcmp(dst, "home") == 0;
|
||||||
|
|
||||||
TEST_DIRUP_EXIT:
|
TEST_DIRUP_EXIT:
|
||||||
return wapp_tester_result(result);
|
return wapp_tester_result(result);
|
||||||
|
Loading…
Reference in New Issue
Block a user