- Timestamp:
- Sep 11, 2015 8:16:53 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTUri.cpp
r57723 r57724 54 54 const char *pszHost; 55 55 uint32_t uPort; 56 57 const char *pszCreated; 56 58 } g_aTests[] = 57 59 { … … 67 69 /*.pszHost =*/ "example.com", 68 70 /*.uPort =*/ 8042, 71 /*.pszCreated =*/ NULL /* same as pszUri*/, 69 72 }, 70 73 { /* #1 */ … … 79 82 /*.pszHost =*/ "example.com", 80 83 /*.uPort =*/ 8042, 84 /*.pszCreated =*/ NULL /* same as pszUri*/, 81 85 }, 82 86 { /* #2 */ … … 91 95 /*.pszHost =*/ "example.com", 92 96 /*.uPort =*/ 8042, 97 /*.pszCreated =*/ NULL /* same as pszUri*/, 93 98 }, 94 99 { /* #3 */ … … 103 108 /*.pszHost =*/ NULL, 104 109 /*.uPort =*/ UINT32_MAX, 110 /*.pszCreated =*/ NULL /* same as pszUri*/, 105 111 }, 106 112 { /* #4 */ … … 115 121 /*.pszHost =*/ NULL, 116 122 /*.uPort =*/ UINT32_MAX, 123 /*.pszCreated =*/ NULL /* same as pszUri*/, 117 124 }, 118 125 { /* #5 */ … … 127 134 /*.pszHost =*/ NULL, 128 135 /*.uPort =*/ UINT32_MAX, 136 /*.pszCreated =*/ NULL /* same as pszUri*/, 129 137 }, 130 138 { /* #6 */ … … 139 147 /*.pszHost =*/ NULL, 140 148 /*.uPort =*/ UINT32_MAX, 149 /*.pszCreated =*/ NULL /* same as pszUri*/, 141 150 }, 142 151 { /* #7 */ … … 151 160 /*.pszHost =*/ NULL, 152 161 /*.uPort =*/ UINT32_MAX, 162 /*.pszCreated =*/ NULL /* same as pszUri*/, 153 163 }, 154 164 { /* #8 */ … … 163 173 /*.pszHost =*/ NULL, 164 174 /*.uPort =*/ UINT32_MAX, 175 /*.pszCreated =*/ NULL /* same as pszUri*/, 165 176 }, 166 177 { /* #9 */ … … 175 186 /*.pszHost =*/ "example.com", 176 187 /*.uPort =*/ 8042, 188 /*.pszCreated =*/ NULL /* same as pszUri*/, 177 189 }, 178 190 { /* #10 */ … … 187 199 /*.pszHost =*/ "example.com", 188 200 /*.uPort =*/ 8042, 201 /*.pszCreated =*/ NULL /* same as pszUri*/, 189 202 }, 190 203 { /* #11 */ … … 199 212 /*.pszHost =*/ "example.com", 200 213 /*.uPort =*/ 8042, 214 /*.pszCreated =*/ NULL /* same as pszUri*/, 201 215 }, 202 216 { /* #12 */ … … 211 225 /*.pszHost =*/ "example.com", 212 226 /*.uPort =*/ 8042, 227 /*.pszCreated =*/ NULL /* same as pszUri*/, 213 228 }, 214 229 { /* #13 */ … … 223 238 /*.pszHost =*/ "example.com", 224 239 /*.uPort =*/ 8042, 240 /*.pszCreated =*/ NULL /* same as pszUri*/, 225 241 }, 226 242 { /* #14 */ … … 235 251 /*.pszHost =*/ NULL, 236 252 /*.uPort =*/ UINT32_MAX, 253 /*.pszCreated =*/ NULL /* same as pszUri*/, 237 254 }, 238 255 { /* #15 */ … … 247 264 /*.pszHost =*/ NULL, 248 265 /*.uPort =*/ UINT32_MAX, 266 /*.pszCreated =*/ NULL /* same as pszUri*/, 267 }, 268 { /* #16 - UTF-8 escape sequences. */ 269 "http://example.com/%ce%b3%ce%bb%cf%83%ce%b1%20%e0%a4%95\xe0\xa4\x95", 270 /*.pszScheme =*/ "http", 271 /*.pszAuthority =*/ "example.com", 272 /*.pszPath =*/ "/\xce\xb3\xce\xbb\xcf\x83\xce\xb1 \xe0\xa4\x95\xe0\xa4\x95", 273 /*.pszQuery =*/ NULL, 274 /*.pszFragment =*/ NULL, 275 /*.pszUsername =*/ NULL, 276 /*.pszPassword =*/ NULL, 277 /*.pszHost =*/ "example.com", 278 /*.uPort =*/ UINT32_MAX, 279 /*.pszCreated =*/ "http://example.com/\xce\xb3\xce\xbb\xcf\x83\xce\xb1%20\xe0\xa4\x95\xe0\xa4\x95", 249 280 }, 250 281 }; … … 324 355 RTTestBanner(hTest); 325 356 357 #define CHECK_STR_API(a_Call, a_pszExpected) \ 358 do { \ 359 char *pszTmp = a_Call; \ 360 if (a_pszExpected) \ 361 { \ 362 if (!pszTmp) \ 363 RTTestIFailed("#%u: %s returns NULL, expected '%s'", i, #a_Call, a_pszExpected); \ 364 else if (strcmp(pszTmp, a_pszExpected)) \ 365 RTTestIFailed("#%u: %s returns '%s', expected '%s'", i, #a_Call, pszTmp, a_pszExpected); \ 366 } \ 367 else if (pszTmp) \ 368 RTTestIFailed("#%u: %s returns '%s', expected NULL", i, #a_Call, pszTmp); \ 369 RTStrFree(pszTmp); \ 370 } while (0) 371 326 372 RTTestISub("RTUriParse & RTUriParsed*"); 327 373 for (uint32_t i = 0; i < RT_ELEMENTS(g_aTests); i++) … … 331 377 if (RT_SUCCESS(rc)) 332 378 { 333 #define CHECK_STR_API(a_Call, a_pszExpected) \334 do { \335 char *pszTmp = a_Call; \336 if (a_pszExpected) \337 { \338 if (!pszTmp) \339 RTTestIFailed("#%u: %s returns NULL, expected '%s'", i, #a_Call, a_pszExpected); \340 else if (strcmp(pszTmp, a_pszExpected)) \341 RTTestIFailed("#%u: %s returns '%s', expected '%s'", i, #a_Call, pszTmp, a_pszExpected); \342 } \343 else if (pszTmp) \344 RTTestIFailed("#%u: %s returns '%s', expected NULL", i, #a_Call, pszTmp); \345 RTStrFree(pszTmp); \346 } while (0)347 379 CHECK_STR_API(RTUriParsedScheme(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszScheme); 348 380 CHECK_STR_API(RTUriParsedAuthority(g_aTests[i].pszUri, &Parsed), g_aTests[i].pszAuthority); … … 362 394 RTTestISub("RTUriCreate"); 363 395 for (uint32_t i = 0; i < RT_ELEMENTS(g_aTests); i++) 364 tstCreate(i, g_aTests[i].pszScheme, g_aTests[i].pszAuthority, g_aTests[i].pszPath, 365 g_aTests[i].pszQuery, g_aTests[i].pszFragment, g_aTests[i].pszUri); 396 CHECK_STR_API(RTUriCreate(g_aTests[i].pszScheme, g_aTests[i].pszAuthority, g_aTests[i].pszPath, 397 g_aTests[i].pszQuery, g_aTests[i].pszFragment), 398 g_aTests[i].pszCreated ? g_aTests[i].pszCreated : g_aTests[i].pszUri); 366 399 367 400 /* File Uri path */
Note:
See TracChangeset
for help on using the changeset viewer.