1. fixed bug in XmlEncode::encodeTo(): incorrect escaping of UTF-8 symbols

2. added test for XmlEncode in case of UTF-8 symbols
This commit is contained in:
Vladimir Zelyonkin
2016-04-05 10:00:15 +03:00
parent c984fc3ecd
commit 42d4e9f1b0
2 changed files with 7 additions and 4 deletions

View File

@@ -458,10 +458,13 @@ TEST_CASE( "XmlEncode" ) {
REQUIRE( encode( stringWithQuotes, Catch::XmlEncode::ForAttributes ) == "don't "quote" me on that" );
}
SECTION( "string with control char (1)" ) {
REQUIRE( encode( "[\x01]" ) == "[&#x1]" );
REQUIRE( encode( "[\x01]" ) == "[]" );
}
SECTION( "string with control char (x7F)" ) {
REQUIRE( encode( "[\x7F]" ) == "[&#x7F]" );
REQUIRE( encode( "[\x7F]" ) == "[]" );
}
SECTION( "string with utf-8 characters (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>)" ) {
REQUIRE( encode( "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>" ) == "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>" );
}
}