diff --git a/doc/example/limitations_const_parameter_warning.cpp b/doc/example/limitations_const_parameter_warning.cpp index 8f0de3b..942264b 100644 --- a/doc/example/limitations_const_parameter_warning.cpp +++ b/doc/example/limitations_const_parameter_warning.cpp @@ -24,7 +24,7 @@ namespace limitations_const_parameter_warning_explanation { class derived : public base { public: - virtual void method(const int); + void method(const int) override; }; void derived::method(int) {} @@ -35,7 +35,7 @@ namespace { //[ limitations_const_parameter_warning_solution MOCK_BASE_CLASS(mock_base, base) { - void method(const int i) { method_stub(i); } + void method(const int i) override { method_stub(i); } MOCK_METHOD(method_stub, 1, void(int), method) }; //] diff --git a/doc/example/motivation.cpp b/doc/example/motivation.cpp index 100e3cb..91db1b5 100644 --- a/doc/example/motivation.cpp +++ b/doc/example/motivation.cpp @@ -40,7 +40,7 @@ class my_view : public view { public: my_view() : called(false) {} - virtual void display(int result) + void display(int result) override { called = true; value = result; diff --git a/include/turtle/detail/function_impl.hpp b/include/turtle/detail/function_impl.hpp index c11f386..8ad1971 100644 --- a/include/turtle/detail/function_impl.hpp +++ b/include/turtle/detail/function_impl.hpp @@ -102,7 +102,7 @@ namespace mock { namespace detail { context_->remove(*this); } - virtual bool verify() const + bool verify() const override { lock _(mutex_); for(const auto& expectation : expectations_) @@ -120,7 +120,7 @@ namespace mock { namespace detail { return valid_; } - virtual void reset() + void reset() override { lock _(mutex_); valid_ = true; diff --git a/include/turtle/detail/invocation.hpp b/include/turtle/detail/invocation.hpp index 5b711e2..5fb974c 100644 --- a/include/turtle/detail/invocation.hpp +++ b/include/turtle/detail/invocation.hpp @@ -44,7 +44,7 @@ namespace mock { namespace detail { throw std::invalid_argument("'min' > 'max'"); } - virtual bool invoke() + bool invoke() override { if(count_ == max_) return false; @@ -52,16 +52,16 @@ namespace mock { namespace detail { return true; } - virtual bool exhausted() const { return count_ >= max_; } + bool exhausted() const override { return count_ >= max_; } - virtual bool verify() const { return min_ <= count_ && count_ <= max_; } + bool verify() const override { return min_ <= count_ && count_ <= max_; } protected: const std::size_t min_, max_; std::size_t count_; private: - virtual std::ostream& serialize(std::ostream& s) const + std::ostream& serialize(std::ostream& s) const override { return s << "between( " << count_ << "/[" << min_ << ',' << max_ << "] )"; } @@ -73,7 +73,7 @@ namespace mock { namespace detail { explicit exactly(std::size_t count) : between(count, count) {} private: - virtual std::ostream& serialize(std::ostream& s) const + std::ostream& serialize(std::ostream& s) const override { return s << "exactly( " << count_ << '/' << max_ << " )"; } @@ -85,7 +85,7 @@ namespace mock { namespace detail { never() : exactly(0) {} private: - virtual std::ostream& serialize(std::ostream& s) const { return s << "never()"; } + std::ostream& serialize(std::ostream& s) const override { return s << "never()"; } }; class once : public exactly @@ -94,7 +94,7 @@ namespace mock { namespace detail { once() : exactly(1) {} private: - virtual std::ostream& serialize(std::ostream& s) const { return s << "once()"; } + std::ostream& serialize(std::ostream& s) const override { return s << "once()"; } }; class at_least : public between @@ -103,7 +103,7 @@ namespace mock { namespace detail { explicit at_least(std::size_t min) : between(min, (std::numeric_limits::max)()) {} private: - virtual std::ostream& serialize(std::ostream& s) const + std::ostream& serialize(std::ostream& s) const override { return s << "at_least( " << count_ << '/' << min_ << " )"; } @@ -115,7 +115,7 @@ namespace mock { namespace detail { explicit at_most(std::size_t max) : between(0, max) {} private: - virtual std::ostream& serialize(std::ostream& s) const + std::ostream& serialize(std::ostream& s) const override { return s << "at_most( " << count_ << '/' << max_ << " )"; } @@ -127,7 +127,7 @@ namespace mock { namespace detail { unlimited() : at_least(0) {} private: - virtual std::ostream& serialize(std::ostream& s) const { return s << "unlimited()"; } + std::ostream& serialize(std::ostream& s) const override { return s << "unlimited()"; } }; }} // namespace mock::detail diff --git a/include/turtle/detail/object_impl.hpp b/include/turtle/detail/object_impl.hpp index 081aeb2..6555245 100644 --- a/include/turtle/detail/object_impl.hpp +++ b/include/turtle/detail/object_impl.hpp @@ -25,23 +25,23 @@ namespace mock { namespace detail { public: object_impl() : mutex_(std::make_shared()) {} - virtual void add(const void* /*p*/, - verifiable& v, - boost::unit_test::const_string instance, - boost::optional type, - boost::unit_test::const_string name) + void add(const void* /*p*/, + verifiable& v, + boost::unit_test::const_string instance, + boost::optional type, + boost::unit_test::const_string name) override { lock _(mutex_); if(children_.empty()) detail::root.add(*this); children_[&v].update(parent_, instance, type, name); } - virtual void add(verifiable& v) + void add(verifiable& v) override { lock _(mutex_); group_.add(v); } - virtual void remove(verifiable& v) + void remove(verifiable& v) override { lock _(mutex_); group_.remove(v); @@ -50,7 +50,7 @@ namespace mock { namespace detail { detail::root.remove(*this); } - virtual void serialize(std::ostream& s, const verifiable& v) const + void serialize(std::ostream& s, const verifiable& v) const override { lock _(mutex_); const auto it = children_.find(&v); @@ -60,12 +60,12 @@ namespace mock { namespace detail { s << "?"; } - virtual bool verify() const + bool verify() const override { lock _(mutex_); return group_.verify(); } - virtual void reset() + void reset() override { lock _(mutex_); std::shared_ptr guard = shared_from_this(); diff --git a/include/turtle/detail/root.hpp b/include/turtle/detail/root.hpp index 664ce0a..adf9321 100644 --- a/include/turtle/detail/root.hpp +++ b/include/turtle/detail/root.hpp @@ -24,11 +24,11 @@ namespace mock { namespace detail { class root_t : public singleton, public context { public: - virtual void add(const void* p, - verifiable& v, - boost::unit_test::const_string instance, - boost::optional type, - boost::unit_test::const_string name) + void add(const void* p, + verifiable& v, + boost::unit_test::const_string instance, + boost::optional type, + boost::unit_test::const_string name) override { scoped_lock _(mutex_); auto it = children_.lower_bound(&v); @@ -36,13 +36,13 @@ namespace mock { namespace detail { it = children_.insert(it, std::make_pair(&v, counter_child(parents_, p))); it->second.update(instance, type, name); } - virtual void add(verifiable& v) + void add(verifiable& v) override { scoped_lock _(mutex_); group_.add(v); } - virtual void remove(verifiable& v) + void remove(verifiable& v) override { scoped_lock _(mutex_); group_.remove(v); @@ -60,7 +60,7 @@ namespace mock { namespace detail { group_.reset(); } - virtual void serialize(std::ostream& s, const verifiable& v) const + void serialize(std::ostream& s, const verifiable& v) const override { scoped_lock _(mutex_); const auto it = children_.find(&v); diff --git a/include/turtle/stream.hpp b/include/turtle/stream.hpp index 979e6a7..b1bccdf 100644 --- a/include/turtle/stream.hpp +++ b/include/turtle/stream.hpp @@ -46,7 +46,7 @@ namespace detail { namespace conversion { struct holder_imp : holder { explicit holder_imp(const T& t) : t_(t) {} - virtual void serialize(std::ostream& s) const + void serialize(std::ostream& s) const override { // if an error about an ambiguous conversion is generated by the // line below the solution is to add a serialization operator to a diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index 59ed333..5fc72fe 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -392,7 +392,7 @@ private: }; class my_implementation : public my_interface { - virtual void my_method() {} + virtual void my_method() override {} }; } // namespace @@ -591,7 +591,7 @@ struct base }; struct derived : base { - virtual void f() {} + virtual void f() override {} }; } // namespace