Differences From Artifact [aef3727a76]:
- File
tests/OFStringTests.m
— part of check-in
[9da9b2b64c]
at
2014-04-14 00:45:58
on branch trunk
— Coding style
No functional change intended. (user: js, size: 27270) [annotate] [blame] [check-ins using]
To Artifact [3e77d0dde3]:
- File
tests/OFStringTests.m
— part of check-in
[0d37286ccb]
at
2014-05-15 15:17:43
on branch trunk
— Don't embed directives within macro arguments
This is undefined behavior. (user: js, size: 27328) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
346 347 348 349 350 351 352 353 354 355 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) TEST(@"+[pathWithComponents:]", (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]]) && | > > > > > < | < < < > | 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | componentsSeparatedByString: @"XX" options: OF_STRING_SKIP_EMPTY]) && [a count] == 3 && [[a objectAtIndex: i++] isEqual: @"foo"] && [[a objectAtIndex: i++] isEqual: @"bar"] && [[a objectAtIndex: i++] isEqual: @"baz"]) #if !defined(_WIN32) && !defined(__DJGPP__) # define EXPECTED @"foo/bar/baz" #else # define EXPECTED @"foo\\bar\\baz" #endif TEST(@"+[pathWithComponents:]", (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", @"bar", @"baz", nil]]) && [is isEqual: EXPECTED] && (is = [OFString pathWithComponents: [OFArray arrayWithObjects: @"foo", nil]]) && [is isEqual: @"foo"]) #undef EXPECTED TEST(@"-[pathComponents]", /* /tmp */ (a = [@"/tmp" pathComponents]) && [a count] == 2 && [[a objectAtIndex: 0] isEqual: @""] && [[a objectAtIndex: 1] isEqual: @"tmp"] && /* /tmp/ */ |
︙ | ︙ | |||
408 409 410 411 412 413 414 415 416 417 418 419 | [[@"/tmp/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"/tmp/foo/" stringByDeletingLastPathComponent] isEqual: @"/tmp"] && [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) TEST(@"-[stringByDeletingPathExtension]", [[@"foo.bar" stringByDeletingPathExtension] isEqual: @"foo"] && [[@"foo..bar" stringByDeletingPathExtension] isEqual: @"foo."] && [[@"/foo./bar" stringByDeletingPathExtension] isEqual: @"/foo./bar"] && | > > > > > < | < < < < > | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 | [[@"/tmp/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"/tmp/foo/" stringByDeletingLastPathComponent] isEqual: @"/tmp"] && [[@"foo/bar" stringByDeletingLastPathComponent] isEqual: @"foo"] && [[@"/" stringByDeletingLastPathComponent] isEqual: @"/"] && [[@"foo" stringByDeletingLastPathComponent] isEqual: @"."]) #if !defined(_WIN32) && !defined(__DJGPP__) # define EXPECTED @"/foo./bar" #else # define EXPECTED @"\\foo.\\bar" #endif TEST(@"-[stringByDeletingPathExtension]", [[@"foo.bar" stringByDeletingPathExtension] isEqual: @"foo"] && [[@"foo..bar" stringByDeletingPathExtension] isEqual: @"foo."] && [[@"/foo./bar" stringByDeletingPathExtension] isEqual: @"/foo./bar"] && [[@"/foo./bar.baz" stringByDeletingPathExtension] isEqual: EXPECTED] && [[@"foo.bar/" stringByDeletingPathExtension] isEqual: @"foo"] && [[@".foo" stringByDeletingPathExtension] isEqual: @".foo"] && [[@".foo.bar" stringByDeletingPathExtension] isEqual: @".foo"]) #undef EXPECTED TEST(@"-[decimalValue]", [@"1234" decimalValue] == 1234 && [@"\r\n+123 " decimalValue] == 123 && [@"-500\t" decimalValue] == -500 && [@"\t\t\r\n" decimalValue] == 0) |
︙ | ︙ | |||
447 448 449 450 451 452 453 | * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && isnan([@" NAN\t\t" floatValue])) | < | | | | > > > > > | 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 | * floating point numbers, thus we can use == on them. */ TEST(@"-[floatValue]", [@"\t-0.25 " floatValue] == -0.25 && [@"\r-INFINITY\n" floatValue] == -INFINITY && isnan([@" NAN\t\t" floatValue])) #if !defined(__ANDROID__) && !defined(__DJGPP__) # define INPUT @"\t-0x1.FFFFFFFFFFFFFP-1020 " # define EXPECTED -0x1.FFFFFFFFFFFFFP-1020 #else /* Android and DJGPPP do not accept 0x for strtod() */ # define INPUT @"\t-0.123456789 " # define EXPECTED -0.123456789 #endif TEST(@"-[doubleValue]", [INPUT doubleValue] == EXPECTED && [@"\r-INFINITY\n" doubleValue] == -INFINITY && isnan([@" NAN\t\t" doubleValue])) #undef INPUT #undef EXPECTED EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #1", OFInvalidFormatException, [@"abc" decimalValue]) EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #2", OFInvalidFormatException, [@"0a" decimalValue]) EXPECT_EXCEPTION(@"Detect invalid characters in -[decimalValue] #3", OFInvalidFormatException, [@"0 1" decimalValue]) |
︙ | ︙ | |||
503 504 505 506 507 508 509 510 511 512 | [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) TEST(@"-[characters]", (ua = [@"fööbär🀺" characters]) && !memcmp(ua, ucstr + 1, sizeof(ucstr) - 8)) TEST(@"-[UTF16String]", (u16a = [@"fööbär🀺" UTF16String]) && !memcmp(u16a, utf16str + 1, of_string_utf16_length(utf16str) * 2) && (u16a = [@"fööbär🀺" | > > > > > < < < | < | < < < < < > | 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 | [@"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" @"0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF" hexadecimalValue]) TEST(@"-[characters]", (ua = [@"fööbär🀺" characters]) && !memcmp(ua, ucstr + 1, sizeof(ucstr) - 8)) #ifdef OF_BIG_ENDIAN # define SWAPPED_BYTE_ORDER OF_BYTE_ORDER_LITTLE_ENDIAN #else # define SWAPPED_BYTE_ORDER OF_BYTE_ORDER_BIG_ENDIAN #endif TEST(@"-[UTF16String]", (u16a = [@"fööbär🀺" UTF16String]) && !memcmp(u16a, utf16str + 1, of_string_utf16_length(utf16str) * 2) && (u16a = [@"fööbär🀺" UTF16StringWithByteOrder: SWAPPED_BYTE_ORDER]) && !memcmp(u16a, sutf16str + 1, of_string_utf16_length(sutf16str) * 2)) TEST(@"-[UTF16StringLength]", [@"fööbär🀺" UTF16StringLength] == 8) TEST(@"-[UTF32String]", (ua = [@"fööbär🀺" UTF32String]) && !memcmp(ua, ucstr + 1, of_string_utf32_length(ucstr) * 4) && (ua = [@"fööbär🀺" UTF32StringWithByteOrder: SWAPPED_BYTE_ORDER]) && !memcmp(ua, sucstr + 1, of_string_utf32_length(sucstr) * 4)) #undef SWAPPED_BYTE_ORDER TEST(@"-[MD5Hash]", [[@"asdfoobar" MD5Hash] isEqual: @"184dce2ec49b5422c7cfd8728864db4c"]) TEST(@"-[SHA1Hash]", [[@"asdfoobar" SHA1Hash] isEqual: @"f5f81ac0a8b5cbfdc4585ec1ad32e7b3a12b9b49"]) |
︙ | ︙ |