From e4ccdc360ea1f3a0da09a1d207d621755019aebc Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Fri, 8 Mar 2024 14:32:16 +0100 Subject: Rewrite PtrHolder unit test to gtest. --- vespalib/src/tests/sharedptr/CMakeLists.txt | 1 + vespalib/src/tests/sharedptr/ptrholder.cpp | 29 ++++------------------------- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/vespalib/src/tests/sharedptr/CMakeLists.txt b/vespalib/src/tests/sharedptr/CMakeLists.txt index 052efb19447..6e038ed31c5 100644 --- a/vespalib/src/tests/sharedptr/CMakeLists.txt +++ b/vespalib/src/tests/sharedptr/CMakeLists.txt @@ -4,5 +4,6 @@ vespa_add_executable(vespalib_ptrholder_test_app TEST ptrholder.cpp DEPENDS vespalib + GTest::gtest ) vespa_add_test(NAME vespalib_ptrholder_test_app COMMAND vespalib_ptrholder_test_app) diff --git a/vespalib/src/tests/sharedptr/ptrholder.cpp b/vespalib/src/tests/sharedptr/ptrholder.cpp index 8dc3bba2722..e6d1710247b 100644 --- a/vespalib/src/tests/sharedptr/ptrholder.cpp +++ b/vespalib/src/tests/sharedptr/ptrholder.cpp @@ -1,20 +1,11 @@ // Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include -#include +#include using vespalib::PtrHolder; -class Test : public vespalib::TestApp -{ -public: - void testEmpty(); - void testSimple(); - int Main() override; -}; - - struct Data { int ctorCnt; @@ -39,8 +30,7 @@ using PT = std::shared_ptr; using HOLD = PtrHolder; -void -Test::testEmpty() +TEST(PtrHolderTest, test_empty) { HOLD hold; EXPECT_TRUE(hold.get().get() == NULL); @@ -56,8 +46,7 @@ Test::testEmpty() } -void -Test::testSimple() +TEST(PtrHolderTest, test_simple) { Data data; HOLD hold; @@ -86,14 +75,4 @@ Test::testSimple() EXPECT_TRUE(data.dtorCnt == 2); } - -int -Test::Main() -{ - TEST_INIT("ptrholder_test"); - testEmpty(); - testSimple(); - TEST_DONE(); -} - -TEST_APPHOOK(Test) +GTEST_MAIN_RUN_ALL_TESTS() -- cgit v1.2.3