1 /***************************************************************************
2 * Copyright (C) 2006 by Intra2net AG *
5 ***************************************************************************/
10 // #include <stdexcept>
12 #include <cppunit/extensions/TestFactoryRegistry.h>
13 #include <cppunit/ui/text/TestRunner.h>
14 #include <cppunit/extensions/HelperMacros.h>
16 #include <stringfunc.hxx>
19 using namespace CppUnit;
21 class stringfunc : public TestFixture
23 CPPUNIT_TEST_SUITE(stringfunc);
25 CPPUNIT_TEST(smart_html_entites1);
26 CPPUNIT_TEST(smart_html_entites2);
27 CPPUNIT_TEST(smart_html_entites3);
28 CPPUNIT_TEST(smart_html_entites4);
29 CPPUNIT_TEST(smart_html_entites5);
30 CPPUNIT_TEST(smart_html_entites6);
31 CPPUNIT_TEST(smart_html_entites7);
32 CPPUNIT_TEST(strip_html_tags1);
33 CPPUNIT_TEST(strip_html_tags2);
35 CPPUNIT_TEST_SUITE_END();
38 void smart_html_entites1()
40 string output = smart_html_entities("Test");
42 CPPUNIT_ASSERT_EQUAL(string("Test"), output);
45 void smart_html_entites2()
47 string output = smart_html_entities("Täst");
49 CPPUNIT_ASSERT_EQUAL(string("Täst"), output);
52 void smart_html_entites3()
54 string output = smart_html_entities("<>");
56 CPPUNIT_ASSERT_EQUAL(string("<>"), output);
59 void smart_html_entites4()
61 string output = smart_html_entities("<ümlaut>");
63 CPPUNIT_ASSERT_EQUAL(string("<ümlaut>"), output);
66 void smart_html_entites5()
68 string output = smart_html_entities("Test<ümlaut>Blä");
70 CPPUNIT_ASSERT_EQUAL(string("Test<ümlaut>Blä"), output);
73 void smart_html_entites6()
75 string output = smart_html_entities("System > Einstellungen");
77 CPPUNIT_ASSERT_EQUAL(string("System > Einstellungen"), output);
80 void smart_html_entites7()
82 string output = smart_html_entities("Finden Sie <b>auf</b> der Seite <a href=\"fdslfsl\">\"System > Einstellungen\"</a>. Oder etwa nicht?");
84 CPPUNIT_ASSERT_EQUAL(string("Finden Sie <b>auf</b> der Seite <a href=\"fdslfsl\">"System > Einstellungen"</a>. Oder etwa nicht?"), output);
87 void strip_html_tags1()
89 string output = strip_html_tags("Was für ein schöner Tag, finden Sie nicht?");
91 CPPUNIT_ASSERT_EQUAL(string("Was für ein schöner Tag, finden Sie nicht?"), output);
94 void strip_html_tags2()
96 string output = strip_html_tags("Was für ein <a href=\"wikipedia\" target=\"new\">schöner Tag</a>, finden Sie nicht?");
98 CPPUNIT_ASSERT_EQUAL(string("Was für ein schöner Tag, finden Sie nicht?"), output);
102 CPPUNIT_TEST_SUITE_REGISTRATION(stringfunc);