Changeset 76 for trunk/src/cutest_sh_utils.c
- Timestamp:
- Dec 19, 2006, 10:01:59 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cutest_sh_utils.c
r68 r76 6 6 #include "samhain.h" 7 7 #include "sh_utils.h" 8 9 void Test_sl_strlcpy (CuTest *tc) { 10 int ret; 11 char out[] = "aaaaaa"; 12 char in[] = "bbb"; 13 14 ret = sl_strlcpy (NULL, NULL, 0); 15 CuAssertIntEquals(tc, ret, SL_ENONE); 16 17 ret = sl_strlcpy (NULL, in, 0); 18 CuAssertIntEquals(tc, ret, SL_ENULL); 19 20 ret = sl_strlcpy (out, NULL, 0); 21 CuAssertIntEquals(tc, ret, SL_ENONE); 22 23 ret = sl_strlcpy (out, in, 0); 24 CuAssertIntEquals(tc, ret, SL_ENONE); 25 26 ret = sl_strlcpy (out, NULL, 7); 27 CuAssertIntEquals(tc, ret, SL_ENONE); 28 CuAssertStrEquals(tc, "", out); 29 30 out[0] = 'a'; 31 ret = sl_strlcpy (out, in, 4); 32 CuAssertIntEquals(tc, ret, SL_ENONE); 33 CuAssertStrEquals(tc, "bbb", out); 34 CuAssertStrEquals(tc, "aa", &out[4]); 35 36 return; 37 } 38 39 void Test_sl_strlcat (CuTest *tc) { 40 int ret; 41 char out[16] = "aaaaaa"; 42 char in[16] = "bbb"; 43 44 ret = sl_strlcat (NULL, NULL, 0); 45 CuAssertIntEquals(tc, ret, SL_ENONE); 46 47 ret = sl_strlcat (NULL, in, 0); 48 CuAssertIntEquals(tc, ret, SL_ENONE); 49 50 ret = sl_strlcat (out, NULL, 0); 51 CuAssertIntEquals(tc, ret, SL_ENONE); 52 53 ret = sl_strlcat (out, in, 0); 54 CuAssertIntEquals(tc, ret, SL_ENONE); 55 56 ret = sl_strlcat (out, NULL, sizeof(out)); 57 CuAssertIntEquals(tc, ret, SL_ENONE); 58 CuAssertStrEquals(tc, "aaaaaa", out); 59 60 ret = sl_strlcat (out, in, 7); 61 CuAssertIntEquals(tc, ret, SL_ETRUNC); 62 CuAssertStrEquals(tc, "aaaaaa", out); 63 64 ret = sl_strlcat (out, in, 8); 65 CuAssertIntEquals(tc, ret, SL_ETRUNC); 66 CuAssertStrEquals(tc, "aaaaaab", out); 67 68 ret = sl_strlcat (out, in, sizeof(out)); 69 CuAssertIntEquals(tc, ret, SL_ENONE); 70 CuAssertStrEquals(tc, "aaaaaabbbb", out); 71 72 CuAssertStrEquals(tc, "bbb", in); 73 74 return; 75 } 8 76 9 77 void Test_sh_util_acl_compact (CuTest *tc) { … … 238 306 CuAssertIntEquals(tc, ret, S_FALSE); 239 307 308 /* switch on utf8 checking for sh_util_obscurename() */ 309 310 ret = sh_util_obscure_utf8("Y"); 311 CuAssertIntEquals(tc, ret, 0); 240 312 241 313 ret = sh_util_obscure_ok ("0x01,0x02,0x03"); … … 244 316 ret = sh_util_valid_utf8 (input); 245 317 CuAssertIntEquals(tc, ret, S_TRUE); 318 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 319 CuAssertIntEquals(tc, ret, 0); 246 320 247 321 input[0] = '\t'; 248 322 ret = sh_util_valid_utf8 (input); 249 323 CuAssertIntEquals(tc, ret, S_FALSE); 324 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 325 CuAssertIntEquals(tc, ret, -1); 250 326 251 327 input[0] = 0x01; 252 328 ret = sh_util_valid_utf8 (input); 253 329 CuAssertIntEquals(tc, ret, S_TRUE); 330 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 331 CuAssertIntEquals(tc, ret, 0); 254 332 255 333 input[0] = 0x02; 256 334 ret = sh_util_valid_utf8 (input); 257 335 CuAssertIntEquals(tc, ret, S_TRUE); 336 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 337 CuAssertIntEquals(tc, ret, 0); 258 338 259 339 input[0] = 0x03; 260 340 ret = sh_util_valid_utf8 (input); 261 341 CuAssertIntEquals(tc, ret, S_TRUE); 342 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 343 CuAssertIntEquals(tc, ret, 0); 262 344 263 345 input[0] = 0x04; 264 346 ret = sh_util_valid_utf8 (input); 265 347 CuAssertIntEquals(tc, ret, S_FALSE); 348 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 349 CuAssertIntEquals(tc, ret, -1); 350 351 input[0] = 'f'; 352 ret = sh_util_valid_utf8 (input); 353 CuAssertIntEquals(tc, ret, S_TRUE); 354 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 355 CuAssertIntEquals(tc, ret, 0); 356 357 input[5] = ' '; 358 ret = sh_util_valid_utf8 (input); 359 CuAssertIntEquals(tc, ret, S_FALSE); 360 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 361 CuAssertIntEquals(tc, ret, -1); 362 363 input[5] = 'r'; input[3] = ' '; 364 ret = sh_util_valid_utf8 (input); 365 CuAssertIntEquals(tc, ret, S_TRUE); 366 ret = sh_util_obscurename (0, (char *)input, S_FALSE /* no log message */); 367 CuAssertIntEquals(tc, ret, 0); 266 368 267 369 … … 277 379 char input[16] = "foobar"; 278 380 381 /* switch off utf8 checking for sh_util_obscurename() */ 382 383 ret = sh_util_obscure_utf8("N"); 384 CuAssertIntEquals(tc, ret, 0); 385 279 386 ret = sh_util_obscure_ok ("0xA1,0xA2,0xA3"); 280 387 CuAssertIntEquals(tc, ret, 0); … … 303 410 CuAssertIntEquals(tc, ret, -1); 304 411 412 input[0] = 'f'; 413 ret = sh_util_obscurename (0, input, S_FALSE /* no log message */); 414 CuAssertIntEquals(tc, ret, 0); 415 416 input[5] = ' '; 417 ret = sh_util_obscurename (0, input, S_FALSE /* no log message */); 418 CuAssertIntEquals(tc, ret, -1); 419 420 input[5] = 'r'; input[3] = ' '; 421 ret = sh_util_obscurename (0, input, S_FALSE /* no log message */); 422 CuAssertIntEquals(tc, ret, 0); 305 423 #else 306 424 CuAssertIntEquals(tc, ret, 0);
Note:
See TracChangeset
for help on using the changeset viewer.