| 531 | } |
| 532 | |
| 533 | static bool CheckStringOperations() |
| 534 | { |
| 535 | bool res = true; |
| 536 | |
| 537 | // Case conversion should only affect ASCII bytes. |
| 538 | // Test using a UTF-8 Copyright Symbol because its leading byte |
| 539 | // is transformed by MSVC's tolower in a US-ASCII locale. |
| 540 | static std::string const sampleUTF8 = "y\xC2\xA9Z"; // Copyright Symbol |
| 541 | if (kwsys::SystemTools::LowerCase(sampleUTF8) != "y\xC2\xA9z") { |
| 542 | std::cerr << "Problem with LowerCase " << '"' << sampleUTF8 << '"' |
| 543 | << std::endl; |
| 544 | res = false; |
| 545 | } |
| 546 | if (kwsys::SystemTools::UpperCase(sampleUTF8) != "Y\xC2\xA9Z") { |
| 547 | std::cerr << "Problem with UpperCase " << '"' << sampleUTF8 << '"' |
| 548 | << std::endl; |
| 549 | res = false; |
| 550 | } |
| 551 | |
| 552 | std::string test = "mary had a little lamb."; |
| 553 | if (kwsys::SystemTools::CapitalizedWords(test) != |
| 554 | "Mary Had A Little Lamb.") { |
| 555 | std::cerr << "Problem with CapitalizedWords " << '"' << test << '"' |
| 556 | << std::endl; |
| 557 | res = false; |
| 558 | } |
| 559 | |
| 560 | test = "Mary Had A Little Lamb."; |
| 561 | if (kwsys::SystemTools::UnCapitalizedWords(test) != |
| 562 | "mary had a little lamb.") { |
| 563 | std::cerr << "Problem with UnCapitalizedWords " << '"' << test << '"' |
| 564 | << std::endl; |
| 565 | res = false; |
| 566 | } |
| 567 | |
| 568 | test = "MaryHadTheLittleLamb."; |
| 569 | if (kwsys::SystemTools::AddSpaceBetweenCapitalizedWords(test) != |
| 570 | "Mary Had The Little Lamb.") { |
| 571 | std::cerr << "Problem with AddSpaceBetweenCapitalizedWords " << '"' << test |
| 572 | << '"' << std::endl; |
| 573 | res = false; |
| 574 | } |
| 575 | |
| 576 | char* cres = |
| 577 | kwsys::SystemTools::AppendStrings("Mary Had A", " Little Lamb."); |
| 578 | if (strcmp(cres, "Mary Had A Little Lamb.") != 0) { |
| 579 | std::cerr << "Problem with AppendStrings " |
| 580 | << "\"Mary Had A\" \" Little Lamb.\"" << std::endl; |
| 581 | res = false; |
| 582 | } |
| 583 | delete[] cres; |
| 584 | |
| 585 | cres = kwsys::SystemTools::AppendStrings("Mary Had", " A ", "Little Lamb."); |
| 586 | if (strcmp(cres, "Mary Had A Little Lamb.") != 0) { |
| 587 | std::cerr << "Problem with AppendStrings " |
| 588 | << "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl; |
| 589 | res = false; |
| 590 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…