diff options
author | Geir Storli <geirst@verizonmedia.com> | 2019-02-18 13:43:16 +0000 |
---|---|---|
committer | Geir Storli <geirst@verizonmedia.com> | 2019-02-18 13:43:16 +0000 |
commit | a0d5c322fa46e5e3ddc57eb2bfab09b792bd604c (patch) | |
tree | 25b540ca1c3d00e014486efbf93ec4b67db9d04c /storageapi | |
parent | 967cf73255ec1495c5a7bf8070992aa8781ff158 (diff) |
Add gtest runner in storageapi and migrate bucketinfotest from CppUnit to gtest.
Diffstat (limited to 'storageapi')
-rw-r--r-- | storageapi/src/tests/.gitignore | 1 | ||||
-rw-r--r-- | storageapi/src/tests/CMakeLists.txt | 20 | ||||
-rw-r--r-- | storageapi/src/tests/buckets/CMakeLists.txt | 2 | ||||
-rw-r--r-- | storageapi/src/tests/buckets/bucketinfotest.cpp | 37 | ||||
-rw-r--r-- | storageapi/src/tests/gtest_runner.cpp | 14 |
5 files changed, 47 insertions, 27 deletions
diff --git a/storageapi/src/tests/.gitignore b/storageapi/src/tests/.gitignore index 37b74259b4a..29911acfe67 100644 --- a/storageapi/src/tests/.gitignore +++ b/storageapi/src/tests/.gitignore @@ -6,4 +6,5 @@ Makefile docstorage test.vlog testrunner +storageapi_gtest_runner_app storageapi_testrunner_app diff --git a/storageapi/src/tests/CMakeLists.txt b/storageapi/src/tests/CMakeLists.txt index e116be29050..d4486105c8b 100644 --- a/storageapi/src/tests/CMakeLists.txt +++ b/storageapi/src/tests/CMakeLists.txt @@ -1,9 +1,27 @@ # Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +# Runner for unit tests written in gtest. +# NOTE: All new test classes should be added here. +vespa_add_executable(storageapi_gtest_runner_app TEST + SOURCES + gtest_runner.cpp + DEPENDS + storageapi_testbuckets + storageapi + gtest +) + +vespa_add_test( + NAME storageapi_gtest_runner_app + COMMAND storageapi_gtest_runner_app + DEPENDS storageapi_gtest_runner_app +) + +# Runner for unit tests written in CppUnit (DEPRECATED). vespa_add_executable(storageapi_testrunner_app TEST SOURCES testrunner.cpp DEPENDS - storageapi_testbuckets storageapi_testmessageapi storageapi_testmbusprot storageapi diff --git a/storageapi/src/tests/buckets/CMakeLists.txt b/storageapi/src/tests/buckets/CMakeLists.txt index b3514cbd028..42310be56f0 100644 --- a/storageapi/src/tests/buckets/CMakeLists.txt +++ b/storageapi/src/tests/buckets/CMakeLists.txt @@ -4,5 +4,5 @@ vespa_add_library(storageapi_testbuckets bucketinfotest.cpp DEPENDS storageapi - cppunit + gtest ) diff --git a/storageapi/src/tests/buckets/bucketinfotest.cpp b/storageapi/src/tests/buckets/bucketinfotest.cpp index 2870d1ae6f2..c861f961626 100644 --- a/storageapi/src/tests/buckets/bucketinfotest.cpp +++ b/storageapi/src/tests/buckets/bucketinfotest.cpp @@ -1,41 +1,28 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <cppunit/extensions/HelperMacros.h> #include <vespa/storageapi/buckets/bucketinfo.h> +#include <gtest/gtest.h> -namespace storage { -namespace api { - -struct BucketInfo_Test : public CppUnit::TestFixture { - - void testSimple(); - - CPPUNIT_TEST_SUITE(BucketInfo_Test); - CPPUNIT_TEST(testSimple); - CPPUNIT_TEST_SUITE_END(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(BucketInfo_Test); +namespace storage::api { /** Tests simple operations */ -void BucketInfo_Test::testSimple() +TEST(BucketInfoTest, testSimple) { BucketInfo info; - CPPUNIT_ASSERT_EQUAL(false, info.valid()); - CPPUNIT_ASSERT_EQUAL(0u, info.getChecksum()); - CPPUNIT_ASSERT_EQUAL(0u, info.getDocumentCount()); - CPPUNIT_ASSERT_EQUAL(1u, info.getTotalDocumentSize()); + EXPECT_FALSE(info.valid()); + EXPECT_EQ(0u, info.getChecksum()); + EXPECT_EQ(0u, info.getDocumentCount()); + EXPECT_EQ(1u, info.getTotalDocumentSize()); info.setChecksum(0xa000bbbb); info.setDocumentCount(15); info.setTotalDocumentSize(64000); - CPPUNIT_ASSERT_EQUAL(true, info.valid()); - CPPUNIT_ASSERT_EQUAL(0xa000bbbb, info.getChecksum()); - CPPUNIT_ASSERT_EQUAL(15u, info.getDocumentCount()); - CPPUNIT_ASSERT_EQUAL(64000u, info.getTotalDocumentSize()); + EXPECT_TRUE(info.valid()); + EXPECT_EQ(0xa000bbbb, info.getChecksum()); + EXPECT_EQ(15u, info.getDocumentCount()); + EXPECT_EQ(64000u, info.getTotalDocumentSize()); }; -} // api -} // storage +} diff --git a/storageapi/src/tests/gtest_runner.cpp b/storageapi/src/tests/gtest_runner.cpp new file mode 100644 index 00000000000..c37be7231ac --- /dev/null +++ b/storageapi/src/tests/gtest_runner.cpp @@ -0,0 +1,14 @@ +// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <gtest/gtest.h> + +#include <vespa/log/log.h> +LOG_SETUP("storageapi_gtest_runner"); + +int +main(int argc, char* argv[]) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} + |