diff options
author | Geir Storli <geirst@vespa.ai> | 2024-03-08 20:41:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-08 20:41:12 +0100 |
commit | ee1d102e10424dd5d30f1139a35cfc0c185b6222 (patch) | |
tree | cc1380e305a426b4e8ae18376ecab24dbab8abfd /vespalib/src | |
parent | 1138035f6bb35ccc0c4218844850634f11adeab2 (diff) | |
parent | 34294a13ca8b7c7622f0dbea597462475f2c62a9 (diff) |
Merge pull request #30535 from vespa-engine/toregge/rewrite-xml-serializable-unit-test-to-gtest
Rewrite XmlSerializable unit test to gtest.
Diffstat (limited to 'vespalib/src')
-rw-r--r-- | vespalib/src/tests/xmlserializable/CMakeLists.txt | 1 | ||||
-rw-r--r-- | vespalib/src/tests/xmlserializable/xmlserializabletest.cpp | 47 |
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><>&	 \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() |