summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2024-03-08 15:27:16 +0100
committerTor Egge <Tor.Egge@online.no>2024-03-08 15:27:16 +0100
commit34294a13ca8b7c7622f0dbea597462475f2c62a9 (patch)
treea0054384cd62e67cccbaf3835d5d377d0a52a851
parent3ede5019a6fe0881917b165166f413c532fe4bc0 (diff)
Rewrite XmlSerializable unit test to gtest.
-rw-r--r--vespalib/src/tests/xmlserializable/CMakeLists.txt1
-rw-r--r--vespalib/src/tests/xmlserializable/xmlserializabletest.cpp47
2 files changed, 11 insertions, 37 deletions
diff --git a/vespalib/src/tests/xmlserializable/CMakeLists.txt b/vespalib/src/tests/xmlserializable/CMakeLists.txt
index 740f1f49bfb..4bd28a668a0 100644
--- a/vespalib/src/tests/xmlserializable/CMakeLists.txt
+++ b/vespalib/src/tests/xmlserializable/CMakeLists.txt
@@ -4,5 +4,6 @@ vespa_add_executable(vespalib_xmlserializable_test_app TEST
xmlserializabletest.cpp
DEPENDS
vespalib
+ GTest::gtest
)
vespa_add_test(NAME vespalib_xmlserializable_test_app COMMAND vespalib_xmlserializable_test_app)
diff --git a/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp b/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp
index c4d3fb9f1b9..3a6b933491a 100644
--- a/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp
+++ b/vespalib/src/tests/xmlserializable/xmlserializabletest.cpp
@@ -1,35 +1,11 @@
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/gtest/gtest.h>
#include <vespa/vespalib/util/xmlstream.h>
namespace vespalib {
-class Test : public vespalib::TestApp
-{
-public:
- void testNormalUsage();
- void testEscaping();
- void testNesting();
- void testIndent();
-
- int Main() override;
-};
-
-int
-Test::Main()
-{
- TEST_INIT("xmlserializables_test");
- srandom(1);
- testNormalUsage();
- testEscaping();
- testNesting();
- testIndent();
- TEST_DONE();
-}
-
-void
-Test::testNormalUsage()
+TEST(XmlSerializableTest, test_normal_usage)
{
std::ostringstream ost;
XmlOutputStream xos(ost);
@@ -47,11 +23,10 @@ Test::testNormalUsage()
"<door windowstate=\"up\"/>\n"
"<description>This is a car description used to test</description>\n"
"</car>";
- EXPECT_EQUAL(expected, ost.str());
+ EXPECT_EQ(expected, ost.str());
}
-void
-Test::testEscaping()
+TEST(XmlSerializableTest, test_escaping)
{
std::ostringstream ost;
XmlOutputStream xos(ost);
@@ -83,7 +58,7 @@ Test::testEscaping()
"<auto1>&lt;&gt;&amp;&#9;&#12;&#13;\nfoo</auto1>\n"
"<auto2 binaryencoding=\"base64\">PD4mCQANCmZvbw==</auto2>\n"
"</__trash_->";
- EXPECT_EQUAL(expected, ost.str());
+ EXPECT_EQ(expected, ost.str());
}
namespace {
@@ -103,8 +78,7 @@ namespace {
};
}
-void
-Test::testNesting()
+TEST(XmlSerializableTest, test_nesting)
{
std::ostringstream ost;
XmlOutputStream xos(ost);
@@ -127,11 +101,10 @@ Test::testNesting()
"</door>\n"
"<description>This is a car description used to test</description>\n"
"</car>";
- EXPECT_EQUAL(expected, ost.str());
+ EXPECT_EQ(expected, ost.str());
}
-void
-Test::testIndent()
+TEST(XmlSerializableTest, test_indent)
{
std::ostringstream ost;
XmlOutputStream xos(ost, " ");
@@ -155,9 +128,9 @@ Test::testIndent()
" <base binaryencoding=\"base64\">Zm9vYmFy</base>\n"
" </nytag>\n"
"</foo>";
- EXPECT_EQUAL(expected, ost.str());
+ EXPECT_EQ(expected, ost.str());
}
} // vespalib
-TEST_APPHOOK(vespalib::Test)
+GTEST_MAIN_RUN_ALL_TESTS()