Make UTF-8 checking into a unit test with Catch

This commit is contained in:
Eric Fischer
2016-10-05 14:55:32 -07:00
parent ef38318a6d
commit 9806db3c0a
7 changed files with 10628 additions and 43 deletions
+11
View File
@@ -0,0 +1,11 @@
#define CATCH_CONFIG_MAIN
#include "catch/catch.hpp"
#include "text.hpp"
TEST_CASE("UTF-8 enforcement", "[utf8]") {
REQUIRE(check_utf8("") == std::string(""));
REQUIRE(check_utf8("hello world") == std::string(""));
REQUIRE(check_utf8("Καλημέρα κόσμε") == std::string(""));
REQUIRE(check_utf8("こんにちは 世界") == std::string(""));
REQUIRE(check_utf8("Hola m\xF3n") == std::string("\"Hola m\xF3n\" is not valid UTF-8 (0xF3 0x6E)"));
}