mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-03 21:49:32 +01:00 
			
		
		
		
	Add tests for StringRef::numberOfCharacters
This commit is contained in:
		@@ -36,7 +36,7 @@ namespace Catch {
 | 
			
		||||
    }
 | 
			
		||||
} // namespace Catch
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "StringRef", "[Strings]" ) {
 | 
			
		||||
TEST_CASE( "StringRef", "[Strings][StringRef]" ) {
 | 
			
		||||
 | 
			
		||||
    using Catch::StringRef;
 | 
			
		||||
 | 
			
		||||
@@ -164,9 +164,21 @@ TEST_CASE( "StringRef", "[Strings]" ) {
 | 
			
		||||
            REQUIRE( stdStr.size() == sr.size() );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SECTION( "Counting utf-8 codepoints" ) {
 | 
			
		||||
        StringRef ascii = "just a plain old boring ascii string...";
 | 
			
		||||
        REQUIRE(ascii.numberOfCharacters() == ascii.size());
 | 
			
		||||
 | 
			
		||||
        StringRef simpleu8 = u8"Trocha češtiny nikoho nezabila";
 | 
			
		||||
        REQUIRE(simpleu8.numberOfCharacters() == 30);
 | 
			
		||||
 | 
			
		||||
        StringRef emojis = u8"Here be 👾";
 | 
			
		||||
        REQUIRE(emojis.numberOfCharacters() == 9);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "replaceInPlace" ) {
 | 
			
		||||
TEST_CASE( "replaceInPlace", "[Strings][StringManip]" ) {
 | 
			
		||||
    std::string letters = "abcdefcg";
 | 
			
		||||
    SECTION( "replace single char" ) {
 | 
			
		||||
        CHECK( Catch::replaceInPlace( letters, "b", "z" ) );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user