diff options
Diffstat (limited to 'vespalib/src/tests')
7 files changed, 50 insertions, 21 deletions
diff --git a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp index 6e8e6e5f761..739f036fb5c 100644 --- a/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp +++ b/vespalib/src/tests/net/async_resolver/async_resolver_test.cpp @@ -22,12 +22,15 @@ struct MyClock : public AsyncResolver::Clock { using time_point = AsyncResolver::time_point; using seconds = AsyncResolver::seconds; time_point my_now; + ~MyClock() override; void set_now(seconds t) { my_now = time_point(std::chrono::duration_cast<time_point::duration>(t)); } AsyncResolver::time_point now() override { return my_now; } }; +MyClock::~MyClock() = default; + struct BlockingHostResolver : public AsyncResolver::HostResolver { CountDownLatch callers; Gate barrier; diff --git a/vespalib/src/tests/rendezvous/rendezvous_test.cpp b/vespalib/src/tests/rendezvous/rendezvous_test.cpp index 616824af7f1..11bcf62d77e 100644 --- a/vespalib/src/tests/rendezvous/rendezvous_test.cpp +++ b/vespalib/src/tests/rendezvous/rendezvous_test.cpp @@ -15,6 +15,7 @@ struct Value { template <typename T, bool ext_id> struct Empty : Rendezvous<int, T, ext_id> { Empty(size_t n) : Rendezvous<int, T, ext_id>(n) {} + ~Empty() override; void mingle() override {} T meet(size_t thread_id) { if constexpr (ext_id) { @@ -26,6 +27,9 @@ struct Empty : Rendezvous<int, T, ext_id> { } }; +template <typename T, bool ext_id> +Empty<T, ext_id>::~Empty() = default; + template <bool ext_id> struct Add : Rendezvous<size_t, std::pair<size_t, size_t>, ext_id> { using Super = Rendezvous<size_t, std::pair<size_t, size_t>, ext_id>; @@ -33,6 +37,7 @@ struct Add : Rendezvous<size_t, std::pair<size_t, size_t>, ext_id> { using Super::in; using Super::out; Add(size_t n) : Super(n) {} + ~Add() override; void mingle() override { size_t sum = 0; for (size_t i = 0; i < size(); ++i) { @@ -45,12 +50,16 @@ struct Add : Rendezvous<size_t, std::pair<size_t, size_t>, ext_id> { }; template <bool ext_id> +Add<ext_id>::~Add() = default; + +template <bool ext_id> struct Modify : Rendezvous<size_t, size_t, ext_id> { using Super = Rendezvous<size_t, size_t, ext_id>; using Super::size; using Super::in; using Super::out; Modify(size_t n) : Super(n) {} + ~Modify() override; void mingle() override { for (size_t i = 0; i < size(); ++i) { in(i) += 1; @@ -61,6 +70,9 @@ struct Modify : Rendezvous<size_t, size_t, ext_id> { } }; +template <bool ext_id> +Modify<ext_id>::~Modify() = default; + template <typename T, bool ext_id> struct Swap : Rendezvous<T, T, ext_id> { using Super = Rendezvous<T, T, ext_id>; @@ -68,12 +80,16 @@ struct Swap : Rendezvous<T, T, ext_id> { using Super::in; using Super::out; Swap() : Super(2) {} + ~Swap() override; void mingle() override { out(0) = std::move(in(1)); out(1) = std::move(in(0)); } }; +template <typename T, bool ext_id> +Swap<T, ext_id>::~Swap() = default; + template <bool ext_id> struct DetectId : Rendezvous<int, size_t, ext_id> { using Super = Rendezvous<int, size_t, ext_id>; @@ -81,6 +97,7 @@ struct DetectId : Rendezvous<int, size_t, ext_id> { using Super::in; using Super::out; DetectId(size_t n) : Super(n) {} + ~DetectId() override; void mingle() override { for (size_t i = 0; i < size(); ++i) { out(i) = i; @@ -96,8 +113,12 @@ struct DetectId : Rendezvous<int, size_t, ext_id> { } }; +template <bool ext_id> +DetectId<ext_id>::~DetectId() = default; + struct Any : Rendezvous<bool, bool> { Any(size_t n) : Rendezvous<bool, bool>(n) {} + ~Any() override; void mingle() override { bool result = false; for (size_t i = 0; i < size(); ++i) { @@ -110,6 +131,8 @@ struct Any : Rendezvous<bool, bool> { bool check(bool flag) { return this->rendezvous(flag); } }; +Any::~Any() = default; + TEST("require that creating an empty rendezvous will fail") { EXPECT_EXCEPTION(Add<false>(0), IllegalArgumentException, ""); EXPECT_EXCEPTION(Add<true>(0), IllegalArgumentException, ""); diff --git a/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp b/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp index 8d5d393fe22..5d69a18112a 100644 --- a/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp +++ b/vespalib/src/tests/simple_thread_bundle/simple_thread_bundle_test.cpp @@ -37,12 +37,15 @@ struct State { struct Blocker : Runnable { Gate start; + ~Blocker() override; void run() override { start.await(); } Gate done; // set externally }; +Blocker::~Blocker() = default; + TEST_MT_FF("require that signals can be counted and cancelled", 2, Signal, size_t(16000)) { if (thread_id == 0) { for (size_t i = 0; i < f2; ++i) { diff --git a/vespalib/src/tests/stllike/hash_test.cpp b/vespalib/src/tests/stllike/hash_test.cpp index 5cba6f73e10..c530bbdb14a 100644 --- a/vespalib/src/tests/stllike/hash_test.cpp +++ b/vespalib/src/tests/stllike/hash_test.cpp @@ -455,8 +455,8 @@ class WrappedKey public: WrappedKey() : _key() { } WrappedKey(int key) : _key(std::make_unique<const int>(key)) { } - size_t hash() const { return vespalib::hash<int>()(*_key); } - bool operator==(const WrappedKey &rhs) const { return *_key == *rhs._key; } + size_t hash() const noexcept { return vespalib::hash<int>()(*_key); } + bool operator==(const WrappedKey &rhs) const noexcept { return *_key == *rhs._key; } }; } diff --git a/vespalib/src/tests/stllike/hashtable_test.cpp b/vespalib/src/tests/stllike/hashtable_test.cpp index 74490e413d1..ccb1136729e 100644 --- a/vespalib/src/tests/stllike/hashtable_test.cpp +++ b/vespalib/src/tests/stllike/hashtable_test.cpp @@ -17,7 +17,7 @@ using namespace vespalib; namespace { template<typename T> -struct Dereference : std::unary_function<T, std::unique_ptr<T>> { +struct Dereference { T &operator()(std::unique_ptr<T>& p) const { return *p; } const T& operator()(const std::unique_ptr<T>& p) const { return *p; } }; @@ -119,7 +119,7 @@ TEST("require that you can insert duplicates") { } template<typename To, typename Vector> -struct FirstInVector : std::unary_function<To, Vector> { +struct FirstInVector { To &operator()(Vector& v) const { return v[0]; } const To& operator()(const Vector& v) const { return v[0]; } }; diff --git a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp index 86c3dc1411c..7b9dfc98fa5 100644 --- a/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp +++ b/vespalib/src/tests/stllike/uniq_by_sort_map_hash.cpp @@ -92,7 +92,7 @@ private: Gid _gid; }; -struct IndirectCmp : public std::binary_function<Slot*, Slot*, bool> { +struct IndirectCmp { bool operator() (const Slot* s1, const Slot* s2) noexcept { return s1->cmp(*s2) < 0; } diff --git a/vespalib/src/tests/testapp-debug/debugtest.cpp b/vespalib/src/tests/testapp-debug/debugtest.cpp index 2ff7affc323..78bf3d69215 100644 --- a/vespalib/src/tests/testapp-debug/debugtest.cpp +++ b/vespalib/src/tests/testapp-debug/debugtest.cpp @@ -5,25 +5,25 @@ using namespace vespalib; void testDebug() { TEST_DEBUG("lhs.out", "rhs.out"); - EXPECT_EQUAL("a\n" - "b\n" - "c\n", + EXPECT_EQUAL(string("a\n" + "b\n" + "c\n"), - "a\n" - "b\n" - "c\n" - "d\n"); - EXPECT_EQUAL("a\n" - "d\n" - "b\n" - "c\n", + string("a\n" + "b\n" + "c\n" + "d\n")); + EXPECT_EQUAL(string("a\n" + "d\n" + "b\n" + "c\n"), - "a\n" - "b\n" - "c\n" - "d\n"); + string("a\n" + "b\n" + "c\n" + "d\n")); EXPECT_EQUAL(1, 2); - EXPECT_EQUAL("foo", "bar"); + EXPECT_EQUAL(string("foo"), string("bar")); } TEST_MAIN() { |