diff --git a/CMakeLists.txt b/CMakeLists.txt index d159c758..7c27d8bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ option_depr (VALGRIND_TESTS CUKE_TESTS_VALGRIND) # if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra ${CMAKE_CXX_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_INIT} -Werror -Wall -Wextra -Wsuggest-override ${CMAKE_CXX_FLAGS}") # TODO: A better fix should handle ld's --as-needed flag if(UNIX AND NOT APPLE) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Xlinker '--no-as-needed'") diff --git a/examples/CalcQt/src/CalculatorWidget.h b/examples/CalcQt/src/CalculatorWidget.h index c029e5fa..dc077556 100644 --- a/examples/CalcQt/src/CalculatorWidget.h +++ b/examples/CalcQt/src/CalculatorWidget.h @@ -16,8 +16,8 @@ class CalculatorWidget : public QWidget { protected: - virtual void keyPressEvent(QKeyEvent *event); - virtual void keyReleaseEvent(QKeyEvent *event); + void keyPressEvent(QKeyEvent *event) override; + void keyReleaseEvent(QKeyEvent *event) override; private: diff --git a/include/cucumber-cpp/internal/CukeEngine.hpp b/include/cucumber-cpp/internal/CukeEngine.hpp index 9f5fa7f2..c8e0e7bc 100644 --- a/include/cucumber-cpp/internal/CukeEngine.hpp +++ b/include/cucumber-cpp/internal/CukeEngine.hpp @@ -36,7 +36,7 @@ class CUCUMBER_CPP_EXPORT InvokeException { const std::string getMessage() const; - virtual ~InvokeException() {} + virtual ~InvokeException() = default; }; class CUCUMBER_CPP_EXPORT InvokeFailureException : public InvokeException { @@ -99,7 +99,7 @@ class CukeEngine { virtual std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const = 0; CUCUMBER_CPP_EXPORT CukeEngine(); - CUCUMBER_CPP_EXPORT virtual ~CukeEngine(); + CUCUMBER_CPP_EXPORT virtual ~CukeEngine() = default; }; } diff --git a/include/cucumber-cpp/internal/CukeEngineImpl.hpp b/include/cucumber-cpp/internal/CukeEngineImpl.hpp index c53f736d..a7b6f0d8 100644 --- a/include/cucumber-cpp/internal/CukeEngineImpl.hpp +++ b/include/cucumber-cpp/internal/CukeEngineImpl.hpp @@ -19,11 +19,11 @@ class CUCUMBER_CPP_EXPORT CukeEngineImpl : public CukeEngine { CukeCommands cukeCommands; public: - std::vector stepMatches(const std::string & name) const; - void beginScenario(const tags_type & tags); - void invokeStep(const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg); - void endScenario(const tags_type & tags); - std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const; + std::vector stepMatches(const std::string & name) const override; + void beginScenario(const tags_type & tags) override; + void invokeStep(const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg) override; + void endScenario(const tags_type & tags) override; + std::string snippetText(const std::string & keyword, const std::string & name, const std::string & multilineArgClass) const override; }; } diff --git a/include/cucumber-cpp/internal/connectors/wire/ProtocolHandler.hpp b/include/cucumber-cpp/internal/connectors/wire/ProtocolHandler.hpp index 43ae4404..16c29b59 100644 --- a/include/cucumber-cpp/internal/connectors/wire/ProtocolHandler.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/ProtocolHandler.hpp @@ -12,7 +12,7 @@ namespace internal { class ProtocolHandler { public: virtual std::string handle(const std::string &request) const = 0; - virtual ~ProtocolHandler() {}; + virtual ~ProtocolHandler() = default; }; } diff --git a/include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp b/include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp index 19a5c64b..7ead98d0 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireProtocol.hpp @@ -22,12 +22,12 @@ class CUCUMBER_CPP_EXPORT WireResponse { virtual void accept(WireResponseVisitor& visitor) const = 0; - virtual ~WireResponse() {}; + virtual ~WireResponse() = default; }; class CUCUMBER_CPP_EXPORT SuccessResponse : public WireResponse { public: - void accept(WireResponseVisitor& visitor) const; + void accept(WireResponseVisitor& visitor) const override; }; class CUCUMBER_CPP_EXPORT FailureResponse : public WireResponse { @@ -40,7 +40,7 @@ class CUCUMBER_CPP_EXPORT FailureResponse : public WireResponse { const std::string getMessage() const; const std::string getExceptionType() const; - void accept(WireResponseVisitor& visitor) const; + void accept(WireResponseVisitor& visitor) const override; }; class CUCUMBER_CPP_EXPORT PendingResponse : public WireResponse { @@ -52,7 +52,7 @@ class CUCUMBER_CPP_EXPORT PendingResponse : public WireResponse { const std::string getMessage() const; - void accept(WireResponseVisitor& visitor) const; + void accept(WireResponseVisitor& visitor) const override; }; class CUCUMBER_CPP_EXPORT StepMatchesResponse : public WireResponse { @@ -63,7 +63,7 @@ class CUCUMBER_CPP_EXPORT StepMatchesResponse : public WireResponse { StepMatchesResponse(const std::vector & matchingSteps); const std::vector& getMatchingSteps() const; - void accept(WireResponseVisitor& visitor) const; + void accept(WireResponseVisitor& visitor) const override; }; class CUCUMBER_CPP_EXPORT SnippetTextResponse : public WireResponse { @@ -75,7 +75,7 @@ class CUCUMBER_CPP_EXPORT SnippetTextResponse : public WireResponse { const std::string getStepSnippet() const; - void accept(WireResponseVisitor& visitor) const; + void accept(WireResponseVisitor& visitor) const override; }; class CUCUMBER_CPP_EXPORT WireResponseVisitor { @@ -86,7 +86,7 @@ class CUCUMBER_CPP_EXPORT WireResponseVisitor { virtual void visit(const StepMatchesResponse& response) = 0; virtual void visit(const SnippetTextResponse& response) = 0; - virtual ~WireResponseVisitor() {}; + virtual ~WireResponseVisitor() = default; }; @@ -104,7 +104,7 @@ class CUCUMBER_CPP_EXPORT WireCommand { */ virtual std::shared_ptr run(CukeEngine& engine) const = 0; - virtual ~WireCommand() {}; + virtual ~WireCommand() = default; }; class CUCUMBER_CPP_EXPORT WireMessageCodecException : public std::exception { @@ -116,7 +116,7 @@ class CUCUMBER_CPP_EXPORT WireMessageCodecException : public std::exception { description(description) { } - const char* what() const throw() { + const char* what() const throw() override { return description; } }; @@ -147,7 +147,7 @@ class CUCUMBER_CPP_EXPORT WireMessageCodec { */ virtual const std::string encode(const WireResponse& response) const = 0; - virtual ~WireMessageCodec() {}; + virtual ~WireMessageCodec() = default; }; /** @@ -155,9 +155,9 @@ class CUCUMBER_CPP_EXPORT WireMessageCodec { */ class CUCUMBER_CPP_EXPORT JsonSpiritWireMessageCodec : public WireMessageCodec { public: - JsonSpiritWireMessageCodec(); - std::shared_ptr decode(const std::string &request) const; - const std::string encode(const WireResponse& response) const; + JsonSpiritWireMessageCodec() = default; + std::shared_ptr decode(const std::string &request) const override; + const std::string encode(const WireResponse& response) const override; }; /** @@ -172,7 +172,7 @@ class CUCUMBER_CPP_EXPORT WireProtocolHandler : public ProtocolHandler { public: WireProtocolHandler(const WireMessageCodec& codec, CukeEngine& engine); - std::string handle(const std::string &request) const; + std::string handle(const std::string &request) const override; }; } diff --git a/include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp b/include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp index 9015d762..9cc09e5f 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireProtocolCommands.hpp @@ -19,7 +19,7 @@ class BeginScenarioCommand : public ScenarioCommand { public: BeginScenarioCommand(const CukeEngine::tags_type& tags); - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; @@ -27,7 +27,7 @@ class EndScenarioCommand : public ScenarioCommand { public: EndScenarioCommand(const CukeEngine::tags_type& tags); - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; @@ -38,7 +38,7 @@ class StepMatchesCommand : public WireCommand { public: StepMatchesCommand(const std::string & stepName); - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; @@ -53,7 +53,7 @@ class InvokeCommand : public WireCommand { const CukeEngine::invoke_args_type& args, const CukeEngine::invoke_table_type& tableArg); - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; @@ -66,13 +66,13 @@ class SnippetTextCommand : public WireCommand { const std::string & name, const std::string & multilineArgClass); - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; class FailingCommand : public WireCommand { public: - std::shared_ptr run(CukeEngine& engine) const; + std::shared_ptr run(CukeEngine& engine) const override; }; } diff --git a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp index 78b32c9c..f6d4e801 100644 --- a/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp +++ b/include/cucumber-cpp/internal/connectors/wire/WireServer.hpp @@ -20,7 +20,7 @@ class CUCUMBER_CPP_EXPORT SocketServer { * Constructor for DI */ SocketServer(const ProtocolHandler *protocolHandler); - virtual ~SocketServer() {} + virtual ~SocketServer() = default; /** * Accept one connection @@ -81,7 +81,7 @@ class CUCUMBER_CPP_EXPORT TCPSocketServer : public SocketServer { */ boost::asio::ip::tcp::endpoint listenEndpoint() const; - virtual void acceptOnce(); + void acceptOnce() override; private: boost::asio::ip::tcp::acceptor acceptor; @@ -111,9 +111,9 @@ class CUCUMBER_CPP_EXPORT UnixSocketServer : public SocketServer { */ boost::asio::local::stream_protocol::endpoint listenEndpoint() const; - virtual void acceptOnce(); + void acceptOnce() override; - ~UnixSocketServer(); + ~UnixSocketServer() override; private: boost::asio::local::stream_protocol::acceptor acceptor; diff --git a/include/cucumber-cpp/internal/drivers/BoostDriver.hpp b/include/cucumber-cpp/internal/drivers/BoostDriver.hpp index 8482ebcc..9518837e 100644 --- a/include/cucumber-cpp/internal/drivers/BoostDriver.hpp +++ b/include/cucumber-cpp/internal/drivers/BoostDriver.hpp @@ -11,7 +11,7 @@ class CukeBoostLogInterceptor; class CUCUMBER_CPP_EXPORT BoostStep : public BasicStep { protected: - const InvokeResult invokeStepBody(); + const InvokeResult invokeStepBody() override; private: static void initBoostTest(); diff --git a/include/cucumber-cpp/internal/drivers/GTestDriver.hpp b/include/cucumber-cpp/internal/drivers/GTestDriver.hpp index 7b4a3f24..20bc0cfb 100644 --- a/include/cucumber-cpp/internal/drivers/GTestDriver.hpp +++ b/include/cucumber-cpp/internal/drivers/GTestDriver.hpp @@ -11,7 +11,7 @@ namespace internal { class CUCUMBER_CPP_EXPORT GTestStep : public BasicStep { protected: - const InvokeResult invokeStepBody(); + const InvokeResult invokeStepBody() override; private: void initGTest(); diff --git a/include/cucumber-cpp/internal/drivers/GenericDriver.hpp b/include/cucumber-cpp/internal/drivers/GenericDriver.hpp index e7fc7e20..afe53566 100644 --- a/include/cucumber-cpp/internal/drivers/GenericDriver.hpp +++ b/include/cucumber-cpp/internal/drivers/GenericDriver.hpp @@ -9,7 +9,7 @@ namespace internal { class CUCUMBER_CPP_EXPORT GenericStep : public BasicStep { protected: - virtual const InvokeResult invokeStepBody(); + const InvokeResult invokeStepBody() override; }; #define STEP_INHERITANCE(step_name) virtual ::cucumber::internal::GenericStep diff --git a/include/cucumber-cpp/internal/drivers/QtTestDriver.hpp b/include/cucumber-cpp/internal/drivers/QtTestDriver.hpp index ca433a7c..1e2f3360 100644 --- a/include/cucumber-cpp/internal/drivers/QtTestDriver.hpp +++ b/include/cucumber-cpp/internal/drivers/QtTestDriver.hpp @@ -15,7 +15,7 @@ class CUCUMBER_CPP_EXPORT QtTestStep : public BasicStep { QtTestStep() : BasicStep() {} protected: - const InvokeResult invokeStepBody(); + const InvokeResult invokeStepBody() override; }; #define STEP_INHERITANCE(step_name) ::cucumber::internal::QtTestStep @@ -24,7 +24,6 @@ class QtTestObject : public QObject { Q_OBJECT public: QtTestObject(QtTestStep* qtTestStep) : step(qtTestStep) {} - virtual ~QtTestObject() {} protected: QtTestStep* step; diff --git a/include/cucumber-cpp/internal/hook/HookRegistrar.hpp b/include/cucumber-cpp/internal/hook/HookRegistrar.hpp index 0e665c0e..91a37d9a 100644 --- a/include/cucumber-cpp/internal/hook/HookRegistrar.hpp +++ b/include/cucumber-cpp/internal/hook/HookRegistrar.hpp @@ -21,7 +21,7 @@ class CUCUMBER_CPP_EXPORT CallableStep { class CUCUMBER_CPP_EXPORT Hook { public: - virtual ~Hook() {} + virtual ~Hook() = default; void setTags(const std::string &csvTagNotation); virtual void invokeHook(Scenario *scenario, CallableStep *step); @@ -42,8 +42,8 @@ class CUCUMBER_CPP_EXPORT BeforeHook : public Hook {}; class CUCUMBER_CPP_EXPORT AroundStepHook : public Hook { public: - virtual void invokeHook(Scenario *scenario, CallableStep *step); - virtual void skipHook(); + void invokeHook(Scenario *scenario, CallableStep *step) override; + void skipHook() override; protected: CallableStep *step; }; @@ -54,7 +54,7 @@ class CUCUMBER_CPP_EXPORT AfterHook : public Hook {}; class CUCUMBER_CPP_EXPORT UnconditionalHook : public Hook { public: - virtual void invokeHook(Scenario *scenario, CallableStep *step); + void invokeHook(Scenario *scenario, CallableStep *step) override; }; class CUCUMBER_CPP_EXPORT BeforeAllHook : public UnconditionalHook {}; @@ -124,7 +124,7 @@ class CUCUMBER_CPP_EXPORT StepCallChain { class CUCUMBER_CPP_EXPORT CallableStepChain : public CallableStep { public: CallableStepChain(StepCallChain *scc); - void call(); + void call() override; private: StepCallChain *scc; }; diff --git a/include/cucumber-cpp/internal/hook/Tag.hpp b/include/cucumber-cpp/internal/hook/Tag.hpp index d0855ac0..ce57d642 100644 --- a/include/cucumber-cpp/internal/hook/Tag.hpp +++ b/include/cucumber-cpp/internal/hook/Tag.hpp @@ -14,14 +14,14 @@ class CUCUMBER_CPP_EXPORT TagExpression { public: typedef std::vector tag_list; - virtual ~TagExpression() { } + virtual ~TagExpression() = default; virtual bool matches(const tag_list &tags) const = 0; }; class CUCUMBER_CPP_EXPORT OrTagExpression : public TagExpression { public: OrTagExpression(const std::string &csvTagNotation); - bool matches(const tag_list &tags) const; + bool matches(const tag_list &tags) const override; private: bool orTagMatchesTagList(const std::string ¤tOrTag, const tag_list &tags) const; @@ -33,9 +33,9 @@ class CUCUMBER_CPP_EXPORT OrTagExpression : public TagExpression { class CUCUMBER_CPP_EXPORT AndTagExpression : public TagExpression { public: - AndTagExpression(); + AndTagExpression() = default; AndTagExpression(const std::string &csvTagNotation); - bool matches(const tag_list &tags) const; + bool matches(const tag_list &tags) const override; private: typedef std::vector or_expressions_type; diff --git a/include/cucumber-cpp/internal/step/StepManager.hpp b/include/cucumber-cpp/internal/step/StepManager.hpp index a72a70e9..f414e523 100644 --- a/include/cucumber-cpp/internal/step/StepManager.hpp +++ b/include/cucumber-cpp/internal/step/StepManager.hpp @@ -57,7 +57,7 @@ class CUCUMBER_CPP_EXPORT InvokeArgs { public: typedef args_type::size_type size_type; - InvokeArgs() { } + InvokeArgs() = default; void addArg(const std::string arg); Table & getVariableTableArg(); @@ -101,7 +101,7 @@ class CUCUMBER_CPP_EXPORT StepInfo : public std::enable_shared_from_this submatches_type; - virtual ~RegexMatch() {}; + virtual ~RegexMatch() = default; bool matches(); const submatches_type & getSubmatches(); diff --git a/src/CukeEngine.cpp b/src/CukeEngine.cpp index 6d021f2d..34eda122 100644 --- a/src/CukeEngine.cpp +++ b/src/CukeEngine.cpp @@ -41,6 +41,5 @@ PendingStepException::PendingStepException(const PendingStepException &rhs) : CukeEngine::CukeEngine() {} -CukeEngine::~CukeEngine() {} } } diff --git a/src/Tag.cpp b/src/Tag.cpp index 79ab06f6..c8a8bf26 100644 --- a/src/Tag.cpp +++ b/src/Tag.cpp @@ -9,8 +9,6 @@ Regex & AndTagExpression::csvTagNotationRegex() { return r; } -AndTagExpression::AndTagExpression() {} - AndTagExpression::AndTagExpression(const std::string &csvTagNotation) { const std::shared_ptr match(csvTagNotationRegex().findAll(csvTagNotation)); const RegexMatch::submatches_type submatches = match->getSubmatches(); diff --git a/src/connectors/wire/WireProtocol.cpp b/src/connectors/wire/WireProtocol.cpp index 69480688..dc35a9f7 100644 --- a/src/connectors/wire/WireProtocol.cpp +++ b/src/connectors/wire/WireProtocol.cpp @@ -173,8 +173,6 @@ static const std::map commandDecodersMap = { {"snippet_text" , SnippetTextDecoder }, }; -JsonSpiritWireMessageCodec::JsonSpiritWireMessageCodec() {} - std::shared_ptr JsonSpiritWireMessageCodec::decode(const std::string &request) const { std::istringstream is(request); mValue json; @@ -229,11 +227,11 @@ namespace { return write_string(v, ::raw_utf8); } - void visit(const SuccessResponse& /*response*/) { + void visit(const SuccessResponse& /*response*/) override { success(); } - void visit(const FailureResponse& response) { + void visit(const FailureResponse& response) override { mObject detailObject; if (!response.getMessage().empty()) { detailObject["message"] = response.getMessage(); @@ -249,12 +247,12 @@ namespace { } } - void visit(const PendingResponse& response) { + void visit(const PendingResponse& response) override { mValue jsonReponse(response.getMessage()); output("pending", &jsonReponse); } - void visit(const StepMatchesResponse& response) { + void visit(const StepMatchesResponse& response) override { mArray jsonMatches; for(const StepMatch & m : response.getMatchingSteps()) { mObject jsonM; @@ -279,7 +277,7 @@ namespace { output("success", &jsonReponse); } - void visit(const SnippetTextResponse& response) { + void visit(const SnippetTextResponse& response) override { mValue jsonReponse(response.getStepSnippet()); success(&jsonReponse); } diff --git a/src/drivers/BoostDriver.cpp b/src/drivers/BoostDriver.cpp index f83ed45f..9213c55b 100644 --- a/src/drivers/BoostDriver.cpp +++ b/src/drivers/BoostDriver.cpp @@ -46,33 +46,33 @@ class CukeBoostLogInterceptor : public ::boost::unit_test::unit_test_log_formatt void reset(); // Formatter - void log_start( std::ostream&, counter_t /*test_cases_amount*/) {}; - void log_finish( std::ostream&) {}; + void log_start( std::ostream&, counter_t /*test_cases_amount*/) override {}; + void log_finish( std::ostream&) override {}; #if BOOST_VERSION >= 107000 - void log_build_info(std::ostream&, bool /*log_build_info*/){}; + void log_build_info(std::ostream&, bool /*log_build_info*/) override {}; #else - void log_build_info( std::ostream&) {}; + void log_build_info( std::ostream&) override {}; #endif - void test_unit_start( std::ostream&, test_unit const& /*tu*/) {}; - void test_unit_finish( std::ostream&, test_unit const& /*tu*/, unsigned long /*elapsed*/) {}; - void test_unit_skipped( std::ostream&, test_unit const& /*tu*/) {}; + void test_unit_start( std::ostream&, test_unit const& /*tu*/) override {}; + void test_unit_finish( std::ostream&, test_unit const& /*tu*/, unsigned long /*elapsed*/) override {}; + void test_unit_skipped( std::ostream&, test_unit const& /*tu*/) override {}; - void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const&) {}; - void log_exception_finish( std::ostream& ) {}; + void log_exception_start( std::ostream&, log_checkpoint_data const&, execution_exception const&) override {}; + void log_exception_finish( std::ostream& ) override {}; - void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types /*let*/) {}; - void log_entry_value( std::ostream&, const_string value); - void log_entry_value( std::ostream&, lazy_ostream const& value); - void log_entry_finish( std::ostream&) {}; + void log_entry_start( std::ostream&, log_entry_data const&, log_entry_types /*let*/) override {}; + void log_entry_value( std::ostream&, const_string value) override; + void log_entry_value( std::ostream&, lazy_ostream const& value) override; + void log_entry_finish( std::ostream&) override {}; - void entry_context_start( std::ostream&, log_level /*l*/) {} + void entry_context_start( std::ostream&, log_level /*l*/) override {} #if BOOST_VERSION >= 106500 - void log_entry_context( std::ostream&, log_level /*l*/, const_string /*value*/) {} - void entry_context_finish( std::ostream&, log_level /*l*/ ) {} + void log_entry_context( std::ostream&, log_level /*l*/, const_string /*value*/) override {} + void entry_context_finish( std::ostream&, log_level /*l*/ ) override {} #else - void log_entry_context( std::ostream&, const_string /*value*/) {} - void entry_context_finish( std::ostream& ) {} + void log_entry_context( std::ostream&, const_string /*value*/) override {} + void entry_context_finish( std::ostream& ) override {} #endif private: diff --git a/tests/integration/ContextHandlingTest.cpp b/tests/integration/ContextHandlingTest.cpp index b3806c65..55c034cf 100644 --- a/tests/integration/ContextHandlingTest.cpp +++ b/tests/integration/ContextHandlingTest.cpp @@ -14,7 +14,7 @@ class ContextHandlingTest : public ::testing::Test { ContextManagerTestDouble contextManager; private: - void TearDown() { + void TearDown() override { contextManager.purgeContexts(); } }; diff --git a/tests/integration/StepRegistrationTest.cpp b/tests/integration/StepRegistrationTest.cpp index 8978c44e..b8614355 100644 --- a/tests/integration/StepRegistrationTest.cpp +++ b/tests/integration/StepRegistrationTest.cpp @@ -10,7 +10,7 @@ using namespace cucumber::internal; class ManualStep : public GenericStep { public: - void body() {}; + void body() override {}; //private: static const int cukeRegId; }; diff --git a/tests/integration/WireProtocolTest.cpp b/tests/integration/WireProtocolTest.cpp index da5479a1..3c85560e 100644 --- a/tests/integration/WireProtocolTest.cpp +++ b/tests/integration/WireProtocolTest.cpp @@ -11,20 +11,17 @@ using namespace testing; class MockCukeEngine : public CukeEngine { public: - MOCK_CONST_METHOD1(stepMatches, std::vector(const std::string & name)); - MOCK_METHOD1(endScenario, void(const tags_type & tags)); - MOCK_METHOD3(invokeStep, void(const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg)); - MOCK_METHOD1(beginScenario, void(const tags_type & tags)); - MOCK_CONST_METHOD3(snippetText, std::string(const std::string & keyword, const std::string & name, const std::string & multilineArgClass)); + MOCK_METHOD(std::vector, stepMatches, (const std::string & name), (const, override)); + MOCK_METHOD(void, endScenario, (const tags_type & tags), (override)); + MOCK_METHOD(void, invokeStep, (const std::string & id, const invoke_args_type & args, const invoke_table_type & tableArg), (override)); + MOCK_METHOD(void, beginScenario, (const tags_type & tags), (override)); + MOCK_METHOD(std::string, snippetText, (const std::string & keyword, const std::string & name, const std::string & multilineArgClass), (const, override)); }; #define EXPECT_PTRTYPE(classname, expression) \ EXPECT_NE(dynamic_cast(expression), (void*)NULL) class WireMessageCodecTest : public Test { -public: - WireMessageCodecTest() {}; - protected: std::shared_ptr commandAutoPtr; diff --git a/tests/integration/WireServerTest.cpp b/tests/integration/WireServerTest.cpp index 26ca78d7..fe953e57 100644 --- a/tests/integration/WireServerTest.cpp +++ b/tests/integration/WireServerTest.cpp @@ -53,7 +53,7 @@ MATCHER_P(EventuallyReceives, value, "") { class MockProtocolHandler : public ProtocolHandler { public: - MOCK_CONST_METHOD1(handle, std::string(const std::string& request)); + MOCK_METHOD(std::string, handle, (const std::string& request), (const, override)); }; class SocketServerTest : public Test { @@ -62,12 +62,12 @@ class SocketServerTest : public Test { StrictMock protocolHandler; std::future serverThread{}; - virtual void SetUp() { + void SetUp() override { SocketServer* server = createListeningServer(); serverThread = std::async(std::launch::async, &SocketServer::acceptOnce, server); } - virtual void TearDown() { + void TearDown() override { serverThread.wait_for(THREAD_TEST_TIMEOUT); destroyListeningServer(); } @@ -80,13 +80,13 @@ class TCPSocketServerTest : public SocketServerTest { protected: std::unique_ptr server; - virtual SocketServer* createListeningServer() { + SocketServer* createListeningServer() override { server.reset(new TCPSocketServer(&protocolHandler)); server->listen(0); return server.get(); } - virtual void destroyListeningServer() { + void destroyListeningServer() override { server.reset(); } }; @@ -142,13 +142,13 @@ class TCPSocketServerLocalhostTest : public SocketServerTest { protected: std::unique_ptr server; - virtual SocketServer* createListeningServer() { + SocketServer* createListeningServer() override { server.reset(new TCPSocketServer(&protocolHandler)); server->listen(tcp::endpoint(boost::asio::ip::address::from_string("127.0.0.1"), 0)); return server.get(); } - virtual void destroyListeningServer() { + void destroyListeningServer() override { server.reset(); } }; @@ -171,14 +171,14 @@ class UnixSocketServerTest : public SocketServerTest { protected: std::unique_ptr server; - virtual SocketServer* createListeningServer() { + SocketServer* createListeningServer() override { const std::string filename = std::filesystem::temp_directory_path() / randomString(); server.reset(new UnixSocketServer(&protocolHandler)); server->listen(filename); return server.get(); } - virtual void destroyListeningServer() { + void destroyListeningServer() override { server.reset(); } diff --git a/tests/integration/drivers/BoostDriverTest.cpp b/tests/integration/drivers/BoostDriverTest.cpp index d442e73f..c2364243 100644 --- a/tests/integration/drivers/BoostDriverTest.cpp +++ b/tests/integration/drivers/BoostDriverTest.cpp @@ -40,16 +40,16 @@ namespace boost { class BoostStepDouble : public BoostStep { public: - const InvokeResult invokeStepBody() { + const InvokeResult invokeStepBody() override { return BoostStep::invokeStepBody(); }; - void body() {}; + void body() override {}; }; class BoostDriverTest : public DriverTest { public: - virtual void runAllTests() { + void runAllTests() override { stepInvocationInitsBoostTest(); DriverTest::runAllTests(); } diff --git a/tests/integration/drivers/GTestDriverTest.cpp b/tests/integration/drivers/GTestDriverTest.cpp index 35ce6b4e..658ef34a 100644 --- a/tests/integration/drivers/GTestDriverTest.cpp +++ b/tests/integration/drivers/GTestDriverTest.cpp @@ -31,16 +31,16 @@ class GTestStepDouble : public GTestStep { return GTestStep::initialized; } - const InvokeResult invokeStepBody() { + const InvokeResult invokeStepBody() override { return GTestStep::invokeStepBody(); }; - void body() {}; + void body() override {}; }; class GTestDriverTest : public DriverTest { public: - virtual void runAllTests() { + void runAllTests() override { stepInvocationInitsGTest(); DriverTest::runAllTests(); } diff --git a/tests/integration/drivers/QtTestDriverTest.cpp b/tests/integration/drivers/QtTestDriverTest.cpp index 6f4373f6..170b9a00 100644 --- a/tests/integration/drivers/QtTestDriverTest.cpp +++ b/tests/integration/drivers/QtTestDriverTest.cpp @@ -29,11 +29,11 @@ class QtTestStepDouble : public QtTestStep { public: QtTestStepDouble() : QtTestStep(), testRun(false) {} - const InvokeResult invokeStepBody() { + const InvokeResult invokeStepBody() override { return QtTestStep::invokeStepBody(); } - void body() { + void body() override { testRun = true; } @@ -42,7 +42,7 @@ class QtTestStepDouble : public QtTestStep { class QtTestDriverTest : public DriverTest { public: - virtual void runAllTests() { + void runAllTests() override { stepInvocationRunsStepBody(); DriverTest::runAllTests(); } diff --git a/tests/unit/BasicStepTest.cpp b/tests/unit/BasicStepTest.cpp index fddd691e..2cf2a408 100644 --- a/tests/unit/BasicStepTest.cpp +++ b/tests/unit/BasicStepTest.cpp @@ -7,13 +7,13 @@ using namespace cucumber::internal; #define PENDING_STEP_DESCRIPTION "A description" class PendingStep : public GenericStep { - void body() { + void body() override { pending(); } }; class PendingStepWithDescription : public GenericStep { - void body() { + void body() override { pending(PENDING_STEP_DESCRIPTION); } }; diff --git a/tests/unit/ContextManagerTest.cpp b/tests/unit/ContextManagerTest.cpp index 0e2fc5f4..421cabd8 100644 --- a/tests/unit/ContextManagerTest.cpp +++ b/tests/unit/ContextManagerTest.cpp @@ -15,7 +15,7 @@ class ContextManagerTest : public ::testing::Test { } protected: private: - void TearDown() { + void TearDown() override { contextManager.purgeContexts(); } }; diff --git a/tests/unit/CukeCommandsTest.cpp b/tests/unit/CukeCommandsTest.cpp index 8c00542f..e8607ad6 100644 --- a/tests/unit/CukeCommandsTest.cpp +++ b/tests/unit/CukeCommandsTest.cpp @@ -41,7 +41,7 @@ const string CheckAllParameters::arg_3_string_with_spaces("forty two"); class CheckAllParametersWithoutMacro : public CheckAllParameters { public: - void body() { + void body() override { EXPECT_EQ(arg_0_int, getArgs()->getInvokeArg(0)); EXPECT_EQ((double)arg_0_int, getArgs()->getInvokeArg(0)); EXPECT_NO_THROW(getArgs()->getInvokeArg(0)); @@ -62,7 +62,7 @@ class CheckAllParametersWithoutMacro : public CheckAllParameters { class CheckAllParametersWithMacro : public CheckAllParameters { public: - void body() { + void body() override { REGEX_PARAM(int, got_arg_0_int); EXPECT_EQ(arg_0_int, got_arg_0_int); @@ -92,7 +92,7 @@ class CheckAllParametersWithFuncArgs : public CheckAllParameters { EXPECT_EQ(arg_3_string_with_spaces, got_arg_3_string_with_spaces); } - void body() { + void body() override { return invokeWithArgs(*this, &CheckAllParametersWithFuncArgs::bodyWithArgs); } }; diff --git a/tests/unit/StepCallChainTest.cpp b/tests/unit/StepCallChainTest.cpp index 97be8ab0..d95d64db 100644 --- a/tests/unit/StepCallChainTest.cpp +++ b/tests/unit/StepCallChainTest.cpp @@ -13,7 +13,7 @@ class FakeStepInfo : public StepInfo { result(result) { } - InvokeResult invokeStep(const InvokeArgs *pArgs) const { + InvokeResult invokeStep(const InvokeArgs *pArgs) const override { latestArgsPtr = pArgs; (*markersPtr) << "S"; return result; @@ -36,7 +36,7 @@ class MarkingAroundStepHook : public AroundStepHook { MarkingAroundStepHook() : id(""), markersPtr(0) {}; - void body() { + void body() override { if (markersPtr) { (*markersPtr) << "B" << id; } @@ -61,7 +61,7 @@ class BlockingAroundStepHook : public MarkingAroundStepHook { BlockingAroundStepHook(std::string id, std::stringstream *markersPtr) : MarkingAroundStepHook(id, markersPtr) {}; protected: - virtual void doCall() { + void doCall() override { } }; diff --git a/tests/unit/StepManagerTest.cpp b/tests/unit/StepManagerTest.cpp index 66ab91b1..ae13f96a 100644 --- a/tests/unit/StepManagerTest.cpp +++ b/tests/unit/StepManagerTest.cpp @@ -10,7 +10,6 @@ using namespace cucumber::internal; class StepManagerTest : public ::testing::Test { public: - virtual ~StepManagerTest() {} typedef StepManagerTestDouble StepManager; protected: @@ -65,7 +64,7 @@ class StepManagerTest : public ::testing::Test { MatchResult::match_results_type getResultSetFor(const string &stepMatch) { return StepManager::stepMatches(stepMatch).getResultSet(); } - void TearDown() { + void TearDown() override { StepManager::clearSteps(); } }; diff --git a/tests/utils/CukeCommandsFixture.hpp b/tests/utils/CukeCommandsFixture.hpp index 6111ad3b..93a32c0b 100644 --- a/tests/utils/CukeCommandsFixture.hpp +++ b/tests/utils/CukeCommandsFixture.hpp @@ -11,7 +11,7 @@ using namespace cucumber::internal; class EmptyStep : public GenericStep { - void body() {} + void body() override {} }; class CukeCommandsFixture : public ::testing::Test, public CukeCommands { @@ -35,7 +35,7 @@ class CukeCommandsFixture : public ::testing::Test, public CukeCommands { stepId = StepManager::addStep(std::make_shared >(matcher, "")); } - virtual void TearDown() { + void TearDown() override { StepManager::clearSteps(); } }; diff --git a/tests/utils/DriverTestRunner.hpp b/tests/utils/DriverTestRunner.hpp index efa59dd9..b9fdf16e 100644 --- a/tests/utils/DriverTestRunner.hpp +++ b/tests/utils/DriverTestRunner.hpp @@ -68,6 +68,8 @@ class DriverTest { DriverTest() { failedTests = 0; } + + virtual ~DriverTest() = default; protected: void expectTrue(const char *description, bool condition) { updateState(description, condition); diff --git a/tests/utils/HookRegistrationFixture.hpp b/tests/utils/HookRegistrationFixture.hpp index c57774b0..3a98a104 100644 --- a/tests/utils/HookRegistrationFixture.hpp +++ b/tests/utils/HookRegistrationFixture.hpp @@ -46,7 +46,7 @@ std::string getHookCallMarkers() { class EmptyCallableStep : public CallableStep { public: - void call() {}; + void call() override {}; }; class HookRegistrarDouble : public HookRegistrar { @@ -115,7 +115,7 @@ class HookRegistrationTest : public CukeCommandsFixture { return str; } - void SetUp() { + void SetUp() override { CukeCommandsFixture::SetUp(); clearHookCallMarkers(); addStepToManager(STATIC_MATCHER); diff --git a/tests/utils/StepManagerTestDouble.hpp b/tests/utils/StepManagerTestDouble.hpp index ee3f5c74..02108760 100644 --- a/tests/utils/StepManagerTestDouble.hpp +++ b/tests/utils/StepManagerTestDouble.hpp @@ -10,7 +10,7 @@ namespace internal { class StepInfoNoOp : public StepInfo { public: StepInfoNoOp(const std::string &stepMatcher, const std::string source) : StepInfo(stepMatcher, source) {} - InvokeResult invokeStep(const InvokeArgs*) const { + InvokeResult invokeStep(const InvokeArgs*) const override { return InvokeResult::success(); } }; @@ -24,7 +24,7 @@ class StepInfoPending : public StepInfo { description(description) { } - InvokeResult invokeStep(const InvokeArgs*) const { + InvokeResult invokeStep(const InvokeArgs*) const override { return InvokeResult::pending(description); } }; @@ -40,7 +40,7 @@ class StepInfoWithTableArg : public StepInfo { expectedSize(expectedSize) { } - InvokeResult invokeStep(const InvokeArgs *pArgs) const { + InvokeResult invokeStep(const InvokeArgs *pArgs) const override { if (pArgs->getTableArg().hashes().size() == expectedSize) { return InvokeResult::success(); } else {