/* Initial author: Peter Moulder. Hereby released into the Public Domain. */ #include #include "utest/test-1ary-cases.h" /* mental disclaims all responsibility for this evil idea for testing static functions. The main disadvantages are that we retain any #define's and `using' directives of the included file. */ #include "quote.cpp" struct streq_free2 { bool operator()(char const *exp, char *got) { bool const ret = (strcmp(exp, got) == 0); g_free(got); return ret; } }; static bool test_xml_quoted_strlen() { utest_start("xml_quoted_strlen"); struct Case1 cases[] = { {"", 0}, {"x", 1}, {"Foo", 3}, {"\"", 6}, {"&", 5}, {"<", 4}, {">", 4}, {"a\"b", 8}, {"a\"bd;!@#$%^*(\\)?", 30} }; test_1ary_cases >("xml_quoted_strlen", xml_quoted_strlen, G_N_ELEMENTS(cases), cases); return utest_end(); } static bool test_xml_quote_strdup() { utest_start("xml_quote_strdup"); struct Case1 cases[] = { {"", ""}, {"x", "x"}, {"Foo", "Foo"}, {"\"", """}, {"&", "&"}, {"<", "<"}, {">", ">"}, {"a\"bd;!@#$%^*(\\)?", "a"b<c>d;!@#$%^*(\\)?"} }; test_1ary_cases("xml_quote_strdup", xml_quote_strdup, G_N_ELEMENTS(cases), cases); return utest_end(); } int main() { bool const succ = (test_xml_quoted_strlen() && test_xml_quote_strdup()); return ( succ ? EXIT_SUCCESS : EXIT_FAILURE ); } /* Local Variables: mode:c++ c-file-style:"stroustrup" c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) indent-tabs-mode:nil fill-column:99 End: */ // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :