added some windows tests

This commit is contained in:
Leonard Iklé committed 2018-09-01 14:22:28 +02:00
1 parent 11b0afa6d6
commit 5e17e2be99
7 files changed
+123 -1

No files matched your search

+7
View File
@@ -8,6 +8,7 @@ int basename_root()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/";
cwk_path_get_basename(path, &basename, &length);
@@ -27,6 +28,7 @@ int basename_special_directories()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "..";
cwk_path_get_basename(path, &basename, &length);
@@ -57,6 +59,7 @@ int basename_no_separators()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "file_name";
cwk_path_get_basename(path, &basename, &length);
@@ -76,6 +79,7 @@ int basename_trailing_separators()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt////";
cwk_path_get_basename(path, &basename, &length);
@@ -95,6 +99,7 @@ int basename_trailing_separator()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt/";
cwk_path_get_basename(path, &basename, &length);
@@ -114,6 +119,7 @@ int basename_empty()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "";
cwk_path_get_basename(path, &basename, &length);
@@ -133,6 +139,7 @@ int basename_simple()
const char *path, *basename;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt";
cwk_path_get_basename(path, &basename, &length);
+7
View File
@@ -7,6 +7,7 @@ int dirname_root()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/";
cwk_path_get_dirname(path, &length);
@@ -22,6 +23,7 @@ int dirname_special_directories()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "..";
cwk_path_get_dirname(path, &length);
@@ -44,6 +46,7 @@ int dirname_no_separators()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "file_name";
cwk_path_get_dirname(path, &length);
@@ -59,6 +62,7 @@ int dirname_trailing_separators()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt////";
cwk_path_get_dirname(path, &length);
@@ -74,6 +78,7 @@ int dirname_trailing_separator()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt/";
cwk_path_get_dirname(path, &length);
@@ -89,6 +94,7 @@ int dirname_empty()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "";
cwk_path_get_dirname(path, &length);
@@ -104,6 +110,7 @@ int dirname_simple()
const char *path;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt";
cwk_path_get_dirname(path, &length);
+8
View File
@@ -5,6 +5,7 @@
int extension_check_without()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_has_extension("/my/path")) {
return EXIT_FAILURE;
}
@@ -14,6 +15,7 @@ int extension_check_without()
int extension_check_empty()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_has_extension("")) {
return EXIT_FAILURE;
}
@@ -23,6 +25,7 @@ int extension_check_empty()
int extension_check_simple()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (!cwk_path_has_extension("/my/path.txt")) {
return EXIT_FAILURE;
}
@@ -35,6 +38,7 @@ int extension_get_multiple()
const char *path, *extension;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.abc.txt.tests";
if (!cwk_path_get_extension(path, &extension, &length)) {
return EXIT_FAILURE;
@@ -56,6 +60,7 @@ int extension_get_last()
const char *path, *extension;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.";
if (!cwk_path_get_extension(path, &extension, &length)) {
return EXIT_FAILURE;
@@ -77,6 +82,7 @@ int extension_get_first()
const char *path, *extension;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/.path";
if (!cwk_path_get_extension(path, &extension, &length)) {
return EXIT_FAILURE;
@@ -98,6 +104,7 @@ int extension_get_without()
const char *path, *extension;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path";
if (cwk_path_get_extension(path, &extension, &length)) {
return EXIT_FAILURE;
@@ -111,6 +118,7 @@ int extension_get_simple()
const char *path, *extension;
size_t length;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/my/path.txt";
if (!cwk_path_get_extension(path, &extension, &length)) {
return EXIT_FAILURE;
+6
View File
@@ -3,6 +3,8 @@
int intersection_empty()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_intersection("/", "") != 0) {
return EXIT_FAILURE;
}
@@ -12,6 +14,7 @@ int intersection_empty()
int intersection_double_separator()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_intersection("/this///is/a//test", "/this//is/a///file") !=
12) {
return EXIT_FAILURE;
@@ -22,6 +25,7 @@ int intersection_double_separator()
int intersection_trailing_separator()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a/") != 10) {
return EXIT_FAILURE;
}
@@ -31,6 +35,7 @@ int intersection_trailing_separator()
int intersection_truncated()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a") != 10) {
return EXIT_FAILURE;
}
@@ -40,6 +45,7 @@ int intersection_truncated()
int intersection_simple()
{
cwk_path_set_style(CWK_STYLE_UNIX);
if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a/string") != 10) {
return EXIT_FAILURE;
}
+10
View File
@@ -8,6 +8,8 @@ int segment_type()
const char *path;
struct cwk_segment segment;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/a/./../.folder/..folder";
if (!cwk_path_get_first_segment(path, &segment)) {
@@ -58,6 +60,8 @@ int segment_previous()
const char *path;
struct cwk_segment segment;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/now/hello_world/abc/";
if (!cwk_path_get_last_segment(path, &segment)) {
@@ -96,6 +100,8 @@ int segment_next()
const char *path;
struct cwk_segment segment;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/hello_world/abc/";
if (!cwk_path_get_first_segment(path, &segment)) {
@@ -126,6 +132,8 @@ int segment_last()
const char *path;
struct cwk_segment segment;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/hello_world/abc";
if (!cwk_path_get_last_segment(path, &segment)) {
@@ -154,6 +162,8 @@ int segment_first()
const char *path;
struct cwk_segment segment;
cwk_path_set_style(CWK_STYLE_UNIX);
path = "/hello_world/abc";
if (!cwk_path_get_first_segment(path, &segment)) {
+78
View File
@@ -0,0 +1,78 @@
#include <cwalk.h>
#include <memory.h>
#include <stdlib.h>
#include <string.h>
int windows_get_root_relative()
{
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()
{
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()
{
size_t size;
cwk_path_set_style(CWK_STYLE_WINDOWS);
cwk_path_get_root("\\\\server\\share\\test.txt", &size);
if (size != 9) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int windows_get_root()
{
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()
{
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;
}