Add some test cases for invalid UTF-8 sequences.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 31 Jan 2017 05:27:23 +0000 (14:27 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Tue, 31 Jan 2017 05:27:23 +0000 (14:27 +0900)
tests/test_string.cpp

index abfbd8d2783a8b228aef6e5e9ee4f8731ab2367a..6f00b62d9f6c16ce17b8f9023ac7f45944213de1 100644 (file)
@@ -354,6 +354,12 @@ public:
     CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80\x80"), String::UTF8).isEmpty());
     CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80\x80"), String::UTF8).isEmpty());
 
+    CPPUNIT_ASSERT(String(ByteVector("\xC2"), String::UTF8).isEmpty());
+    CPPUNIT_ASSERT(String(ByteVector("\xE0\x80"), String::UTF8).isEmpty());
+    CPPUNIT_ASSERT(String(ByteVector("\xF0\x80\x80"), String::UTF8).isEmpty());
+    CPPUNIT_ASSERT(String(ByteVector("\xF8\x80\x80\x80"), String::UTF8).isEmpty());
+    CPPUNIT_ASSERT(String(ByteVector("\xFC\x80\x80\x80\x80"), String::UTF8).isEmpty());
+
     CPPUNIT_ASSERT(String('\x80', String::UTF8).isEmpty());
 
     CPPUNIT_ASSERT(String(ByteVector("\xED\xA0\x80\xED\xB0\x80"), String::UTF8).isEmpty());