1 /* 2 * PROJECT: ReactOS API tests 3 * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory 4 * PURPOSE: Test for CheckEscapesA/W 5 * PROGRAMMER: Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com> 6 */ 7 #include "shelltest.h" 8 9 typedef void (WINAPI *FN_CheckEscapesA)(LPSTR string, DWORD len); 10 typedef void (WINAPI *FN_CheckEscapesW)(LPWSTR string, DWORD len); 11 12 static FN_CheckEscapesA s_pCheckEscapesA; 13 static FN_CheckEscapesW s_pCheckEscapesW; 14 15 typedef struct TESTENTRYA 16 { 17 INT lineno; 18 LPCSTR input; 19 DWORD len; 20 LPCSTR output; 21 } TESTENTRYA; 22 23 typedef struct TESTENTRYW 24 { 25 INT lineno; 26 LPCWSTR input; 27 DWORD len; 28 LPCWSTR output; 29 } TESTENTRYW; 30 31 static const TESTENTRYA s_entriesA[] = 32 { 33 { __LINE__, "", 0, "" }, 34 { __LINE__, "", 1, "" }, 35 { __LINE__, "", 2, "" }, 36 { __LINE__, "", 3, "" }, 37 { __LINE__, "", 4, "" }, 38 { __LINE__, "", 5, "" }, 39 { __LINE__, "", 6, "" }, 40 { __LINE__, "ABC", 1, "" }, 41 { __LINE__, "ABC", 2, "A" }, 42 { __LINE__, "ABC", 3, "AB" }, 43 { __LINE__, "ABC", 4, "ABC" }, 44 { __LINE__, "ABC", 5, "ABC" }, 45 { __LINE__, "ABC", 6, "ABC" }, 46 { __LINE__, "AB C", 1, "" }, 47 { __LINE__, "AB C", 2, "A" }, 48 { __LINE__, "AB C", 3, "AB" }, 49 { __LINE__, "AB C", 4, "AB " }, 50 { __LINE__, "AB C", 5, "AB C" }, 51 { __LINE__, "AB C", 6, "\"AB C" }, 52 { __LINE__, "AB C ", 1, "" }, 53 { __LINE__, "AB C ", 2, "A" }, 54 { __LINE__, "AB C ", 3, "AB" }, 55 { __LINE__, "AB C ", 4, "AB " }, 56 { __LINE__, "AB C ", 5, "AB C" }, 57 { __LINE__, "AB C ", 6, "AB C " }, 58 { __LINE__, "AB,", 1, "" }, 59 { __LINE__, "AB,", 2, "A" }, 60 { __LINE__, "AB,", 3, "AB" }, 61 { __LINE__, "AB,", 4, "AB," }, 62 { __LINE__, "AB,", 5, "\"AB," }, 63 { __LINE__, "AB,", 6, "\"AB,\"" }, 64 { __LINE__, "AB\"", 1, "" }, 65 { __LINE__, "AB\"", 2, "A" }, 66 { __LINE__, "AB\"", 3, "AB" }, 67 { __LINE__, "AB\"", 4, "AB\"" }, 68 { __LINE__, "AB\"", 5, "\"AB\"" }, 69 { __LINE__, "AB\"", 6, "\"AB\"\"" }, 70 { __LINE__, "AB;", 1, "" }, 71 { __LINE__, "AB;", 2, "A" }, 72 { __LINE__, "AB;", 3, "AB" }, 73 { __LINE__, "AB;", 4, "AB;" }, 74 { __LINE__, "AB;", 5, "\"AB;" }, 75 { __LINE__, "AB;", 6, "\"AB;\"" }, 76 { __LINE__, "AB^", 1, "" }, 77 { __LINE__, "AB^", 2, "A" }, 78 { __LINE__, "AB^", 3, "AB" }, 79 { __LINE__, "AB^", 4, "AB^" }, 80 { __LINE__, "AB^", 5, "\"AB^" }, 81 { __LINE__, "AB^", 6, "\"AB^\"" }, 82 }; 83 84 static const TESTENTRYW s_entriesW[] = 85 { 86 { __LINE__, L"", 0, L"" }, 87 { __LINE__, L"", 1, L"" }, 88 { __LINE__, L"", 2, L"" }, 89 { __LINE__, L"", 3, L"" }, 90 { __LINE__, L"", 4, L"" }, 91 { __LINE__, L"", 5, L"" }, 92 { __LINE__, L"", 6, L"" }, 93 { __LINE__, L"ABC", 1, L"ABC" }, 94 { __LINE__, L"ABC", 2, L"ABC" }, 95 { __LINE__, L"ABC", 3, L"ABC" }, 96 { __LINE__, L"ABC", 4, L"ABC" }, 97 { __LINE__, L"ABC", 5, L"ABC" }, 98 { __LINE__, L"ABC", 6, L"ABC" }, 99 { __LINE__, L"AB C", 1, L"AB C" }, 100 { __LINE__, L"AB C", 2, L"AB C" }, 101 { __LINE__, L"AB C", 3, L"AB C" }, 102 { __LINE__, L"AB C", 4, L"AB C" }, 103 { __LINE__, L"AB C", 5, L"AB C" }, 104 { __LINE__, L"AB C", 6, L"\"AB C\"" }, 105 { __LINE__, L"AB C ", 1, L"AB C " }, 106 { __LINE__, L"AB C ", 2, L"AB C " }, 107 { __LINE__, L"AB C ", 3, L"AB C " }, 108 { __LINE__, L"AB C ", 4, L"AB C " }, 109 { __LINE__, L"AB C ", 5, L"AB C " }, 110 { __LINE__, L"AB C ", 6, L"AB C " }, 111 { __LINE__, L"AB,", 1, L"AB," }, 112 { __LINE__, L"AB,", 2, L"AB," }, 113 { __LINE__, L"AB,", 3, L"AB," }, 114 { __LINE__, L"AB,", 4, L"AB," }, 115 { __LINE__, L"AB,", 5, L"\"AB,\"" }, 116 { __LINE__, L"AB,", 6, L"\"AB,\"" }, 117 { __LINE__, L"AB\"", 1, L"AB\"" }, 118 { __LINE__, L"AB\"", 2, L"AB\"" }, 119 { __LINE__, L"AB\"", 3, L"AB\"" }, 120 { __LINE__, L"AB\"", 4, L"AB\"" }, 121 { __LINE__, L"AB\"", 5, L"\"AB\"\"" }, 122 { __LINE__, L"AB\"", 6, L"\"AB\"\"" }, 123 { __LINE__, L"AB;", 1, L"AB;" }, 124 { __LINE__, L"AB;", 2, L"AB;" }, 125 { __LINE__, L"AB;", 3, L"AB;" }, 126 { __LINE__, L"AB;", 4, L"AB;" }, 127 { __LINE__, L"AB;", 5, L"\"AB;\"" }, 128 { __LINE__, L"AB;", 6, L"\"AB;\"" }, 129 { __LINE__, L"AB^", 1, L"AB^" }, 130 { __LINE__, L"AB^", 2, L"AB^" }, 131 { __LINE__, L"AB^", 3, L"AB^" }, 132 { __LINE__, L"AB^", 4, L"AB^" }, 133 { __LINE__, L"AB^", 5, L"\"AB^\"" }, 134 { __LINE__, L"AB^", 6, L"\"AB^\"" }, 135 }; 136 137 static void JustDoIt(void) 138 { 139 SIZE_T i, count; 140 CHAR bufA[MAX_PATH]; 141 WCHAR bufW[MAX_PATH]; 142 143 count = _countof(s_entriesA); 144 for (i = 0; i < count; ++i) 145 { 146 lstrcpynA(bufA, s_entriesA[i].input, _countof(bufA)); 147 s_pCheckEscapesA(bufA, s_entriesA[i].len); 148 ok(lstrcmpA(bufA, s_entriesA[i].output) == 0, 149 "Line %d: output expected '%s' vs got '%s'\n", 150 s_entriesA[i].lineno, s_entriesA[i].output, bufA); 151 } 152 153 count = _countof(s_entriesW); 154 for (i = 0; i < count; ++i) 155 { 156 lstrcpynW(bufW, s_entriesW[i].input, _countof(bufW)); 157 s_pCheckEscapesW(bufW, s_entriesW[i].len); 158 ok(lstrcmpW(bufW, s_entriesW[i].output) == 0, 159 "Line %d: output expected '%ls' vs got '%ls'\n", 160 s_entriesW[i].lineno, s_entriesW[i].output, bufW); 161 } 162 } 163 164 START_TEST(CheckEscapes) 165 { 166 HINSTANCE hShell32 = GetModuleHandleA("shell32"); 167 s_pCheckEscapesA = (FN_CheckEscapesA)GetProcAddress(hShell32, "CheckEscapesA"); 168 s_pCheckEscapesW = (FN_CheckEscapesW)GetProcAddress(hShell32, "CheckEscapesW"); 169 if (s_pCheckEscapesA && s_pCheckEscapesW) 170 { 171 JustDoIt(); 172 } 173 else 174 { 175 skip("There is no CheckEscapesA/W\n"); 176 } 177 } 178