From 8674b3d732a2bae43105fb7654d3b8c1c57adb56 Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Thu, 10 Aug 2023 19:42:36 -0700 Subject: [PATCH] Consistently use `override` in tests (#3934) --- .../test.cpp | 2 +- .../test.cpp | 2 +- .../test.cpp | 8 ++--- .../tests/Dev11_0496153_locale_ctor/test.cpp | 2 +- .../test.cpp | 2 +- .../test.cpp | 2 +- .../test.cpp | 25 ++++++++-------- tests/std/tests/P0476R2_bit_cast/test.cpp | 2 +- .../test.cpp | 4 +-- tests/tr1/tests/future1/test.cpp | 12 ++++---- tests/tr1/tests/locale1/test.cpp | 16 +++++----- tests/tr1/tests/locale2/test.cpp | 16 +++++----- tests/tr1/tests/locale3/test.cpp | 30 +++++++++---------- tests/tr1/tests/locale4/test.cpp | 30 +++++++++---------- tests/tr1/tests/memory1/test.cpp | 4 +-- tests/tr1/tests/streambuf1/test.cpp | 26 ++++++++-------- tests/tr1/tests/streambuf2/test.cpp | 26 ++++++++-------- 17 files changed, 104 insertions(+), 105 deletions(-) diff --git a/tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/test.cpp b/tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/test.cpp index 2d40860b02..a996f85425 100644 --- a/tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/test.cpp +++ b/tests/std/tests/Dev09_199123_tr1_mem_fun_abstract_classes/test.cpp @@ -25,7 +25,7 @@ class Base { class Derived : public Base { private: - virtual void purr() {} + void purr() override {} }; int main() { diff --git a/tests/std/tests/Dev10_654977_655012_shared_ptr_move/test.cpp b/tests/std/tests/Dev10_654977_655012_shared_ptr_move/test.cpp index 654d609b90..729ee81c91 100644 --- a/tests/std/tests/Dev10_654977_655012_shared_ptr_move/test.cpp +++ b/tests/std/tests/Dev10_654977_655012_shared_ptr_move/test.cpp @@ -24,7 +24,7 @@ class Base { class Derived : public Base { public: - virtual string str() const { + string str() const override { return "Derived"; } }; diff --git a/tests/std/tests/Dev10_847656_shared_ptr_is_convertible/test.cpp b/tests/std/tests/Dev10_847656_shared_ptr_is_convertible/test.cpp index 730f44cdaa..a2a14df335 100644 --- a/tests/std/tests/Dev10_847656_shared_ptr_is_convertible/test.cpp +++ b/tests/std/tests/Dev10_847656_shared_ptr_is_convertible/test.cpp @@ -18,13 +18,13 @@ class Cat { }; struct Lion : public Cat { - virtual int meow() const { + int meow() const override { return 6; } }; struct Tiger : public Cat { - virtual int meow() const { + int meow() const override { return 7; } }; @@ -42,13 +42,13 @@ class Planet { }; struct Jupiter : public Planet { - virtual int orbit() const { + int orbit() const override { return 8; } }; struct Saturn : public Planet { - virtual int orbit() const { + int orbit() const override { return 9; } }; diff --git a/tests/std/tests/Dev11_0496153_locale_ctor/test.cpp b/tests/std/tests/Dev11_0496153_locale_ctor/test.cpp index 73659075e5..83cf98a779 100644 --- a/tests/std/tests/Dev11_0496153_locale_ctor/test.cpp +++ b/tests/std/tests/Dev11_0496153_locale_ctor/test.cpp @@ -34,7 +34,7 @@ void test_Dev11_496153_locale_ctor_should_not_throw() noexcept { } struct comma_separator : numpunct { - virtual char do_decimal_point() const override { + char do_decimal_point() const override { return ','; } }; diff --git a/tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp b/tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp index 51151f4a36..c81667641e 100644 --- a/tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp +++ b/tests/std/tests/Dev11_0535636_functional_overhaul/test.cpp @@ -741,7 +741,7 @@ struct BaseMeow { }; struct DerivedMeow : BaseMeow { - virtual int operator()(int x, int y) override { + int operator()(int x, int y) override { return x * x * x + y * y * y; } }; diff --git a/tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp b/tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp index 097f9dd14c..9e40990af0 100644 --- a/tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp +++ b/tests/std/tests/Dev11_1066589_shared_ptr_atomic_deadlock/test.cpp @@ -129,7 +129,7 @@ int main() { }; struct Derived final : Base { - virtual void test() override {} + void test() override {} }; shared_ptr object; diff --git a/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp b/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp index d981d14803..5be276e1ac 100644 --- a/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp +++ b/tests/std/tests/P0220R1_polymorphic_memory_resources/test.cpp @@ -158,7 +158,7 @@ namespace { struct malloc_resource final : std::pmr::memory_resource { private: - virtual void* do_allocate(std::size_t bytes, std::size_t align) override { + void* do_allocate(std::size_t bytes, std::size_t align) override { if (!bytes) { return nullptr; } @@ -175,7 +175,7 @@ namespace { throw std::bad_alloc{}; } - virtual void do_deallocate(void* ptr, std::size_t, std::size_t align) noexcept override { + void do_deallocate(void* ptr, std::size_t, std::size_t align) noexcept override { if (align > __STDCPP_DEFAULT_NEW_ALIGNMENT__) { _aligned_free(ptr); } else { @@ -183,7 +183,7 @@ namespace { } } - virtual bool do_is_equal(const memory_resource& that) const noexcept override { + bool do_is_equal(const memory_resource& that) const noexcept override { return typeid(malloc_resource) == typeid(that); } }; @@ -194,7 +194,7 @@ namespace { void* ptr_{}; private: - virtual void* do_allocate(std::size_t bytes, std::size_t align) override { + void* do_allocate(std::size_t bytes, std::size_t align) override { if (bytes_ != 0) { CHECK(bytes == bytes_); } else { @@ -214,7 +214,7 @@ namespace { } } - virtual void do_deallocate(void* ptr, std::size_t bytes, std::size_t align) noexcept override { + void do_deallocate(void* ptr, std::size_t bytes, std::size_t align) noexcept override { if (ptr_) { CHECK(ptr == ptr_); if (bytes_ != 0) { @@ -245,7 +245,7 @@ namespace { } } - virtual bool do_is_equal(const memory_resource& that) const noexcept override { + bool do_is_equal(const memory_resource& that) const noexcept override { CHECK(ptr_ == &that); return typeid(checked_resource) == typeid(that); } @@ -273,14 +273,13 @@ namespace { } } - virtual void* do_allocate(std::size_t const bytes, std::size_t const align) override { + void* do_allocate(std::size_t const bytes, std::size_t const align) override { void* const result = upstream_->allocate(bytes, align); allocations_.push_back({result, bytes, align}); return result; } - virtual void do_deallocate( - void* const ptr, std::size_t const bytes, std::size_t const align) noexcept override { + void do_deallocate(void* const ptr, std::size_t const bytes, std::size_t const align) noexcept override { allocation const alloc{ptr, bytes, align}; auto const end = allocations_.end(); auto pos = std::find(allocations_.begin(), end, alloc); @@ -289,7 +288,7 @@ namespace { upstream_->deallocate(ptr, bytes, align); } - virtual bool do_is_equal(const memory_resource& that) const noexcept override { + bool do_is_equal(const memory_resource& that) const noexcept override { return this == &that; } }; @@ -496,15 +495,15 @@ namespace { struct max_align_checker final : std::pmr::memory_resource { private: - virtual void* do_allocate(std::size_t bytes, std::size_t align) override { + void* do_allocate(std::size_t bytes, std::size_t align) override { CHECK(align == alignof(std::max_align_t)); return std::malloc(bytes); } - virtual void do_deallocate(void* ptr, std::size_t, std::size_t align) override { + void do_deallocate(void* ptr, std::size_t, std::size_t align) override { CHECK(align == alignof(std::max_align_t)); std::free(ptr); } - virtual bool do_is_equal(const memory_resource& that) const noexcept override { + bool do_is_equal(const memory_resource& that) const noexcept override { return typeid(max_align_checker) == typeid(that); } }; diff --git a/tests/std/tests/P0476R2_bit_cast/test.cpp b/tests/std/tests/P0476R2_bit_cast/test.cpp index 288f960b42..1abee26ce0 100644 --- a/tests/std/tests/P0476R2_bit_cast/test.cpp +++ b/tests/std/tests/P0476R2_bit_cast/test.cpp @@ -32,7 +32,7 @@ struct middle_class_2 { }; struct derived_class : middle_class_1, middle_class_2 { - virtual void a_member_function_2() override {} + void a_member_function_2() override {} }; struct test_struct_1 { diff --git a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp index 822a374181..9954c85d77 100644 --- a/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp +++ b/tests/std/tests/P0645R10_text_formatting_formatting/test.cpp @@ -656,11 +656,11 @@ void test_bool_specs() { assert(format(locale{"en-US"}, STR("{:L}"), false) == STR("false")); struct my_bool : numpunct { - virtual basic_string do_truename() const { + basic_string do_truename() const override { return STR("yes"); } - virtual basic_string do_falsename() const { + basic_string do_falsename() const override { return STR("no"); } }; diff --git a/tests/tr1/tests/future1/test.cpp b/tests/tr1/tests/future1/test.cpp index 205deb4f11..a19f5aa7ef 100644 --- a/tests/tr1/tests/future1/test.cpp +++ b/tests/tr1/tests/future1/test.cpp @@ -105,10 +105,10 @@ class future_tester_base { // base class for testing future types with set and g template