diff --git a/worker/api/cpp/unittests/test_worker_api.cpp b/worker/api/cpp/unittests/test_worker_api.cpp index c0bd1d4b46252dec9e96aad82c4694a34595eb53..874a61d47ffd589417b95877efce05cce0eff35f 100644 --- a/worker/api/cpp/unittests/test_worker_api.cpp +++ b/worker/api/cpp/unittests/test_worker_api.cpp @@ -1,4 +1,4 @@ -#include <gtest/gtest.h> +#include <gmock/gmock.h> #include "worker/data_broker.h" #include "../src/folder_data_broker.h" @@ -8,6 +8,10 @@ using hidra2::DataBroker; using hidra2::FolderDataBroker; using hidra2::WorkerErrorCode; +using ::testing::Eq; +using ::testing::Ne; +using ::testing::Test; + namespace { TEST(DataBrokerFactoryTests, CreateFolderDataSource) { @@ -15,8 +19,8 @@ TEST(DataBrokerFactoryTests, CreateFolderDataSource) { auto data_broker = DataBrokerFactory::Create("path/to/file", &return_code); - EXPECT_EQ(return_code, WorkerErrorCode::ERR__NO_ERROR); - EXPECT_NE(dynamic_cast<FolderDataBroker*>(data_broker.release()), nullptr); + ASSERT_THAT(return_code, Eq(WorkerErrorCode::ERR__NO_ERROR)); + ASSERT_THAT(dynamic_cast<FolderDataBroker*>(data_broker.release()), Ne(nullptr)); } TEST(DataBrokerFactoryTests, FailCreateDataSourceWithEmptySource) { @@ -24,11 +28,11 @@ TEST(DataBrokerFactoryTests, FailCreateDataSourceWithEmptySource) { auto data_broker = DataBrokerFactory::Create("", &return_code); - EXPECT_EQ(return_code, WorkerErrorCode::ERR__EMPTY_DATASOURCE); - EXPECT_EQ(data_broker.release(), nullptr); + ASSERT_THAT(return_code, Eq(WorkerErrorCode::ERR__EMPTY_DATASOURCE)); + ASSERT_THAT(data_broker.release(), Eq(nullptr)); } -class FolderDataBrokerTests : public ::testing::Test { +class FolderDataBrokerTests : public Test { public: FolderDataBroker* data_broker; void SetUp() override { @@ -41,11 +45,9 @@ class FolderDataBrokerTests : public ::testing::Test { } }; - -TEST_F(FolderDataBrokerTests, ConnectPreparesFileList){ - auto return_code= data_broker->Connect(); - EXPECT_EQ(return_code, WorkerErrorCode::ERR__NO_ERROR); +TEST_F(FolderDataBrokerTests, ConnectPreparesFileList) { + auto return_code = data_broker->Connect(); + ASSERT_THAT(return_code, Eq(WorkerErrorCode::ERR__NO_ERROR)); } - }