33 CPPUNIT_ASSERT_EQUAL(std::string(
""), std::string(
html_quote(
"")));
34 CPPUNIT_ASSERT_EQUAL(std::string(
"bar"), std::string(
html_quote(
"bar")));
35 CPPUNIT_ASSERT_EQUAL(std::string(
"foo<bar>gazonk"), std::string(
html_quote(
"foo<bar>gazonk")));
36 CPPUNIT_ASSERT_EQUAL(std::string(
"foo&bar"), std::string(
html_quote(
"foo&bar")));
37 CPPUNIT_ASSERT_EQUAL(std::string(
"some'thing"), std::string(
html_quote(
"some'thing")));
38 CPPUNIT_ASSERT_EQUAL(std::string(
"some"thing"), std::string(
html_quote(
"some\"thing")));
39 CPPUNIT_ASSERT_EQUAL(std::string(
"<>"&'"), std::string(
html_quote(
"<>\"&'")));
40 CPPUNIT_ASSERT_EQUAL(std::string(
">"), std::string(
html_quote(
">")));
41 CPPUNIT_ASSERT_EQUAL(std::string(
"£"), std::string(
html_quote(
"\xa3")));
43 for (
unsigned char ch = 1; ch < 0xff; ++ch) {
44 unsigned char buf[2] = {ch,
'\0'};
45 auto quoted =
html_quote(
reinterpret_cast<char *
>(buf));
47 if (strlen(quoted) == 1) {
48 CPPUNIT_ASSERT_EQUAL(
static_cast<int>(ch),
static_cast<int>(quoted[0]));
50 CPPUNIT_ASSERT(strlen(quoted) >= 3);
51 CPPUNIT_ASSERT_EQUAL(
'&', quoted[0]);
52 CPPUNIT_ASSERT_EQUAL(
';', quoted[strlen(quoted)-1]);
53 if (quoted[1] ==
'#') {
54 CPPUNIT_ASSERT(strlen(quoted) > 3);
55 CPPUNIT_ASSERT(strlen(quoted) <= 6);