From 7e5d3cf87d336c3e3f81326908f728a324504cd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Thu, 29 Jul 2010 12:53:55 +0200 Subject: [PATCH] feature #192: Tests for feature #282. (cherry picked from commit ab24a66e0ec8fd28d9387c80c63c3c747a946ab5) --- src/template/test/SConstruct | 3 +++ src/template/test/template.cc | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/template/test/SConstruct b/src/template/test/SConstruct index ccad613e67..630dd30ee2 100644 --- a/src/template/test/SConstruct +++ b/src/template/test/SConstruct @@ -64,6 +64,9 @@ main_env.Append(CPPFLAGS=[ "-Wall" ]) +# libxml2 +main_env.ParseConfig('xml2-config --libs --cflags') + # MYSQL main_env.Append(LIBPATH=["/usr/lib/mysql"]) main_env.Append(CPPPATH=["/usr/include/mysql"]) diff --git a/src/template/test/template.cc b/src/template/test/template.cc index 1dbdbeded2..7f2faeb466 100644 --- a/src/template/test/template.cc +++ b/src/template/test/template.cc @@ -311,6 +311,35 @@ public: CPPUNIT_ASSERT( n == 2 ); } + /* --------------------------------------------------------------------- */ + + void test_from_xml() + { + string str1; + string str2; + Template t_xml; + int rc; + + // Generate a xml from a Template generated from a text template + t1->to_xml(str1); + CPPUNIT_ASSERT(test_ok_xml == str1); + + // Parse the xml in a new Template object + rc = t_xml.from_xml(str1); + CPPUNIT_ASSERT(rc == 0); + + // Check correct output of this xml-generated Template object + t_xml.to_xml(str2); + CPPUNIT_ASSERT(str1 == str2); + + str1 = ""; + str2 = ""; + + t1->to_str(str1); + t_xml.to_str(str2); + + CPPUNIT_ASSERT(str1 == str2); + } /* ********************************************************************* */ /* ********************************************************************* */ @@ -351,6 +380,10 @@ public: "erase() Test", &TemplateTest::test_erase)); + ts->addTest(new CppUnit::TestCaller( + "from_xml() Test", + &TemplateTest::test_from_xml)); + return ts; } };