Files
cwalk/test/windows_test.c

117 lines
2.0 KiB
C
Executable File

#include <cwalk.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
int windows_root_empty(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("", &size);
if (size != 0) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_root_backslash(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("\\no_network_path\\hello", &size);
if (size != 1) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_intersection_case(void)
{
cwk_path_set_style(CWK_STYLE_WINDOWS);
if (cwk_path_get_intersection("C:\\MYFOLDER\\MYILE.TXT",
"c:\\myfolder\\myile.txt") != 21) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_get_root_relative(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("C:file.txt", &size);
if (size != 2) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_get_root_separator(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("C:/this/is/a/test", &size);
if (size != 3) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_get_unc_root(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("\\\\server\\share\\test.txt", &size);
if (size != 15) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_get_root(void)
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("C:\\test.txt", &size);
if (size != 3) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_change_style(void)
{
enum cwk_path_style style;
style = cwk_path_get_style();
if (style == CWK_STYLE_WINDOWS) {
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_style() != CWK_STYLE_UNIX) {
return EXIT_FAILURE;
}
} else {
cwk_path_set_style(CWK_STYLE_WINDOWS);
if (cwk_path_get_style() != CWK_STYLE_WINDOWS) {
return EXIT_FAILURE;
}
}
return EXIT_SUCCESS;
}