diff options
-rw-r--r-- | documentapi/src/tests/loadtypes/CMakeLists.txt | 3 | ||||
-rw-r--r-- | documentapi/src/tests/loadtypes/loadtypetest.cpp | 53 | ||||
-rw-r--r-- | documentapi/src/tests/loadtypes/testrunner.cpp | 12 |
3 files changed, 26 insertions, 42 deletions
diff --git a/documentapi/src/tests/loadtypes/CMakeLists.txt b/documentapi/src/tests/loadtypes/CMakeLists.txt index 7588c091cc2..39ee6816c5e 100644 --- a/documentapi/src/tests/loadtypes/CMakeLists.txt +++ b/documentapi/src/tests/loadtypes/CMakeLists.txt @@ -2,9 +2,10 @@ vespa_add_executable(documentapi_loadtype_test_app TEST SOURCES loadtypetest.cpp - testrunner.cpp DEPENDS documentapi vdstestlib + gmock + gtest ) vespa_add_test(NAME documentapi_loadtype_test_app COMMAND documentapi_loadtype_test_app) diff --git a/documentapi/src/tests/loadtypes/loadtypetest.cpp b/documentapi/src/tests/loadtypes/loadtypetest.cpp index 768b4f3a3ff..33257af4f0e 100644 --- a/documentapi/src/tests/loadtypes/loadtypetest.cpp +++ b/documentapi/src/tests/loadtypes/loadtypetest.cpp @@ -1,52 +1,45 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include <vespa/documentapi/loadtypes/loadtypeset.h> -#include <vespa/vdstestlib/cppunit/macros.h> #include <vespa/config/config.h> #include <vespa/config/common/exceptions.h> +#include <vespa/vespalib/gtest/gtest.h> +#include <gmock/gmock.h> -namespace documentapi { - -struct LoadTypeTest : public CppUnit::TestFixture { - - void testConfig(); +using namespace ::testing; - CPPUNIT_TEST_SUITE(LoadTypeTest); - CPPUNIT_TEST(testConfig); - CPPUNIT_TEST_SUITE_END(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(LoadTypeTest); +namespace documentapi { -#define ASSERT_CONFIG_FAILURE(configId, error) \ - try { \ - LoadTypeSet createdFromConfigId(vespalib::stringref(configId)); \ - CPPUNIT_FAIL("Config was expected to fail with error: " \ - + string(error)); \ - } catch (config::InvalidConfigException& e) { \ - CPPUNIT_ASSERT_CONTAIN(string(error), e.getMessage()); \ +void +assertConfigFailure(const vespalib::string &configId, const vespalib::string &expError) +{ + try { + LoadTypeSet createdFromConfigId(configId); + FAIL() << "Config was expected to fail with error: " << expError; + } catch (config::InvalidConfigException &e) { + EXPECT_THAT(e.getMessage(), HasSubstr(expError)); } +} -void -LoadTypeTest::testConfig() +TEST(LoadTypeTest, testConfig) { - // Using id 0 is illegal. Reserved for default type. - ASSERT_CONFIG_FAILURE( + // Using id 0 is illegal. Reserved for default type. + assertConfigFailure( "raw:" "type[1]\n" "type[0].id 0\n" "type[0].name \"foo\"\n" "type[0].priority \"\"", "Load type identifiers need to be"); - // Using name "default" is illegal. Reserved for default type. - ASSERT_CONFIG_FAILURE( + // Using name "default" is illegal. Reserved for default type. + assertConfigFailure( "raw:" "type[1]\n" "type[0].id 1\n" "type[0].name \"default\"\n" "type[0].priority \"\"", "Load type names need to be"); - // Identifiers need to be unique. - ASSERT_CONFIG_FAILURE( + // Identifiers need to be unique. + assertConfigFailure( "raw:" "type[2]\n" "type[0].id 1\n" @@ -55,8 +48,8 @@ LoadTypeTest::testConfig() "type[1].id 1\n" "type[1].name \"testa\"\n" "type[1].priority \"\"", "Load type identifiers need to be"); - // Names need to be unique. - ASSERT_CONFIG_FAILURE( + // Names need to be unique. + assertConfigFailure( "raw:" "type[2]\n" "type[0].id 1\n" @@ -80,3 +73,5 @@ LoadTypeTest::testConfig() } } // documentapi + +GTEST_MAIN_RUN_ALL_TESTS diff --git a/documentapi/src/tests/loadtypes/testrunner.cpp b/documentapi/src/tests/loadtypes/testrunner.cpp deleted file mode 100644 index 78f58b1168e..00000000000 --- a/documentapi/src/tests/loadtypes/testrunner.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/vdstestlib/cppunit/cppunittestrunner.h> - -#include <vespa/log/log.h> -LOG_SETUP("storagecppunittests"); - -int -main(int argc, const char *argv[]) -{ - vdstestlib::CppUnitTestRunner testRunner; - return testRunner.run(argc, argv); -} |