guess_test.c (2029B)
1 #include <cwalk.h> 2 #include <stdlib.h> 3 4 int guess_empty_string(void) 5 { 6 if (cwk_path_guess_style("") != CWK_STYLE_UNIX) { 7 return EXIT_FAILURE; 8 } 9 10 return EXIT_SUCCESS; 11 } 12 13 int guess_unguessable(void) 14 { 15 if (cwk_path_guess_style("myfile") != CWK_STYLE_UNIX) { 16 return EXIT_FAILURE; 17 } 18 19 return EXIT_SUCCESS; 20 } 21 22 int guess_extension(void) 23 { 24 if (cwk_path_guess_style("myfile.txt") != CWK_STYLE_WINDOWS) { 25 return EXIT_FAILURE; 26 } 27 28 if (cwk_path_guess_style("/a/directory/myfile.txt") != CWK_STYLE_UNIX) { 29 return EXIT_FAILURE; 30 } 31 32 return EXIT_SUCCESS; 33 } 34 35 int guess_hidden_file(void) 36 { 37 if (cwk_path_guess_style(".my_hidden_file") != CWK_STYLE_UNIX) { 38 return EXIT_FAILURE; 39 } 40 41 if (cwk_path_guess_style(".my_hidden_file.txt") != CWK_STYLE_UNIX) { 42 return EXIT_FAILURE; 43 } 44 45 return EXIT_SUCCESS; 46 } 47 48 int guess_unix_separator(void) 49 { 50 if (cwk_path_guess_style("/directory/other") != CWK_STYLE_UNIX) { 51 return EXIT_FAILURE; 52 } 53 54 if (cwk_path_guess_style("/directory/other.txt") != CWK_STYLE_UNIX) { 55 return EXIT_FAILURE; 56 } 57 58 return EXIT_SUCCESS; 59 } 60 61 int guess_windows_separator(void) 62 { 63 if (cwk_path_guess_style("\\directory\\other") != CWK_STYLE_WINDOWS) { 64 return EXIT_FAILURE; 65 } 66 if (cwk_path_guess_style("\\directory\\.other") != CWK_STYLE_WINDOWS) { 67 return EXIT_FAILURE; 68 } 69 70 return EXIT_SUCCESS; 71 } 72 73 int guess_unix_root(void) 74 { 75 if (cwk_path_guess_style("/directory") != CWK_STYLE_UNIX) { 76 return EXIT_FAILURE; 77 } 78 79 return EXIT_SUCCESS; 80 } 81 82 int guess_windows_root(void) 83 { 84 if (cwk_path_guess_style("C:\\test") != CWK_STYLE_WINDOWS) { 85 return EXIT_FAILURE; 86 } 87 88 if (cwk_path_guess_style("C:/test") != CWK_STYLE_WINDOWS) { 89 return EXIT_FAILURE; 90 } 91 92 if (cwk_path_guess_style("C:test") != CWK_STYLE_WINDOWS) { 93 return EXIT_FAILURE; 94 } 95 96 if (cwk_path_guess_style("C:/.test") != CWK_STYLE_WINDOWS) { 97 return EXIT_FAILURE; 98 } 99 100 if (cwk_path_guess_style("C:/folder/.test") != CWK_STYLE_WINDOWS) { 101 return EXIT_FAILURE; 102 } 103 104 return EXIT_SUCCESS; 105 }