]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw_escape.cc: add utf-8 test
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 13 Jul 2011 18:24:48 +0000 (11:24 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 13 Jul 2011 18:46:02 +0000 (11:46 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/test/rgw_escape.cc

index 556af0194599d8d8a18e46907aaa959d4cf783f2..45c26a4106b87049ddbfe05d9ee1615a1b40eb6a 100644 (file)
@@ -44,6 +44,16 @@ TEST(EscapeXml, ControlChars) {
   ASSERT_EQ(escape_xml_attrs((char*)cc2), "abc&#x7f;");
 }
 
+TEST(EscapeXml, Utf8) {
+  uint8_t cc1[] = { 0xe6, 0xb1, 0x89, 0xe5, 0xad, 0x97, 0x0a, 0x0 };
+  ASSERT_EQ(escape_xml_attrs((const char*)cc1), (const char*)cc1);
+
+  uint8_t cc2[] = { 0x3c, 0xe6, 0xb1, 0x89, 0xe5, 0xad, 0x97, 0x3e, 0x0a, 0x0 };
+  uint8_t cc2_out[] = { 0x26, 0x6c, 0x74, 0x3b, 0xe6, 0xb1, 0x89, 0xe5,
+                       0xad, 0x97, 0x26, 0x67, 0x74, 0x3b, 0x0a, 0x0 };
+  ASSERT_EQ(escape_xml_attrs((const char*)cc2), (const char*)cc2_out);
+}
+
 static std::string escape_json_attrs(const char *str)
 {
   int len = escape_json_attr_len(str);