diff options
Diffstat (limited to 'server/src/xml_encode_decode.cc')
-rw-r--r-- | server/src/xml_encode_decode.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/server/src/xml_encode_decode.cc b/server/src/xml_encode_decode.cc index 427e451..1c0e377 100644 --- a/server/src/xml_encode_decode.cc +++ b/server/src/xml_encode_decode.cc @@ -82,23 +82,22 @@ std::string xml_decode(std::string str) } #ifdef TEST_XML_ENCODE_DECODE +//deps: +//cflags: +//libs: +#include <test.h> -int main() -{ - std::string in = "&A<B>C\"D\'<>\"&E<>"; - std::string enc = xml_encode(in); - std::string denc = xml_encode(enc); - std::string dec = xml_decode(denc); - std::string ddec = xml_decode(dec); +TEST_BEGIN; - printf("Input: \"%s\" %d\n", in.c_str(), in.length()); - printf("Encoded: \"%s\" %d\n", enc.c_str(), enc.length()); - printf("DoubleEncoded: \"%s\" %d\n", denc.c_str(), denc.length()); - printf("Decoded: \"%s\" %d\n", dec.c_str(), dec.length()); - printf("DoubleDecoded: \"%s\" %d\n", ddec.c_str(), ddec.length()); +std::string in = "&A<B>C\"D\'<>\"&E<>"; +std::string enc = xml_encode(in); +std::string denc = xml_encode(enc); +std::string dec = xml_decode(denc); +std::string ddec = xml_decode(dec); - if( in == ddec && enc == dec) return 0; - return 1; -} +TEST_EQUAL_STR(in, ddec, "compare"); +TEST_EQUAL_STR(enc, dec, "compare"); + +TEST_END; #endif/*TEST_XML_ENCODE_DECODE*/ |