intersection_test.c (2556B)
1 #include <cwalk.h> 2 #include <stdlib.h> 3 4 int intersection_skipped_end(void) 5 { 6 cwk_path_set_style(CWK_STYLE_UNIX); 7 8 if (cwk_path_get_intersection("/test/foo/har/../", "/test/foo/ho") != 9) { 9 return EXIT_FAILURE; 10 } 11 12 return EXIT_SUCCESS; 13 } 14 15 int intersection_relative_other(void) 16 { 17 cwk_path_set_style(CWK_STYLE_UNIX); 18 19 if (cwk_path_get_intersection("/test/foo/har", "/test/abc/../foo/bar") != 9) { 20 return EXIT_FAILURE; 21 } 22 23 return EXIT_SUCCESS; 24 } 25 26 int intersection_relative_base(void) 27 { 28 cwk_path_set_style(CWK_STYLE_UNIX); 29 30 if (cwk_path_get_intersection("/test/abc/../foo/bar", "/test/foo/har") != 31 16) { 32 return EXIT_FAILURE; 33 } 34 35 return EXIT_SUCCESS; 36 } 37 38 int intersection_one_root_only(void) 39 { 40 cwk_path_set_style(CWK_STYLE_WINDOWS); 41 42 if (cwk_path_get_intersection("C:/abc/test.txt", "C:/") != 3) { 43 return EXIT_FAILURE; 44 } 45 46 return EXIT_SUCCESS; 47 } 48 49 int intersection_same_roots(void) 50 { 51 cwk_path_set_style(CWK_STYLE_WINDOWS); 52 53 if (cwk_path_get_intersection("C:/abc/test.txt", "C:/def/test.txt") != 3) { 54 return EXIT_FAILURE; 55 } 56 57 return EXIT_SUCCESS; 58 } 59 60 int intersection_relative_absolute_mix(void) 61 { 62 cwk_path_set_style(CWK_STYLE_UNIX); 63 64 if (cwk_path_get_intersection("/test/abc.txt", "test/abc.txt") != 0) { 65 return EXIT_FAILURE; 66 } 67 68 return EXIT_SUCCESS; 69 } 70 71 int intersection_unequal_roots(void) 72 { 73 cwk_path_set_style(CWK_STYLE_WINDOWS); 74 75 if (cwk_path_get_intersection("C:/test/abc.txt", "D:/test/abc.txt") != 0) { 76 return EXIT_FAILURE; 77 } 78 79 return EXIT_SUCCESS; 80 } 81 82 int intersection_empty(void) 83 { 84 cwk_path_set_style(CWK_STYLE_UNIX); 85 86 if (cwk_path_get_intersection("/", "") != 0) { 87 return EXIT_FAILURE; 88 } 89 90 return EXIT_SUCCESS; 91 } 92 93 int intersection_double_separator(void) 94 { 95 cwk_path_set_style(CWK_STYLE_UNIX); 96 if (cwk_path_get_intersection("/this///is/a//test", "/this//is/a///file") != 97 12) { 98 return EXIT_FAILURE; 99 } 100 101 return EXIT_SUCCESS; 102 } 103 104 int intersection_trailing_separator(void) 105 { 106 cwk_path_set_style(CWK_STYLE_UNIX); 107 if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a/") != 10) { 108 return EXIT_FAILURE; 109 } 110 111 return EXIT_SUCCESS; 112 } 113 114 int intersection_truncated(void) 115 { 116 cwk_path_set_style(CWK_STYLE_UNIX); 117 if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a") != 10) { 118 return EXIT_FAILURE; 119 } 120 121 return EXIT_SUCCESS; 122 } 123 124 int intersection_simple(void) 125 { 126 cwk_path_set_style(CWK_STYLE_UNIX); 127 if (cwk_path_get_intersection("/this/is/a/test", "/this/is/a/string") != 10) { 128 return EXIT_FAILURE; 129 } 130 131 return EXIT_SUCCESS; 132 }