Umbrella project for an GenericWidgets client using the GenericCore library (Using submodules). With a GoogleTest project testing GenericCore::toString() method.
This commit is contained in:
30
tests/GenericCoreTests/CMakeLists.txt
Normal file
30
tests/GenericCoreTests/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
||||
include(FetchContent)
|
||||
|
||||
set(TARGET_APP "core_test")
|
||||
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG v1.17.0
|
||||
)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
add_library(GTest::GTest INTERFACE IMPORTED)
|
||||
target_link_libraries(GTest::GTest INTERFACE gtest_main)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core LinguistTools)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core LinguistTools)
|
||||
|
||||
add_executable(${TARGET_APP} core_test.cpp)
|
||||
|
||||
target_include_directories(${TARGET_APP} PRIVATE ${CORE_LIB_DIR}/include)
|
||||
|
||||
target_link_libraries(${TARGET_APP}
|
||||
PRIVATE
|
||||
GTest::GTest
|
||||
GenericCore)
|
||||
target_link_libraries(${TARGET_APP} PUBLIC Qt${QT_VERSION_MAJOR}::Core)
|
||||
|
||||
add_test(core_gtests ${TARGET_APP})
|
||||
20
tests/GenericCoreTests/core_test.cpp
Normal file
20
tests/GenericCoreTests/core_test.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "../../libs/GenericCore/genericcore.h"
|
||||
|
||||
TEST(CoreTests, TestEqualString) {
|
||||
const auto expected = "GenericCore (Version x.y.z)";
|
||||
auto core = std::make_unique<GenericCore>();
|
||||
const auto actual = core->toString();
|
||||
// const auto actual = multiply(1, 1);
|
||||
ASSERT_EQ(expected, actual);
|
||||
}
|
||||
|
||||
TEST(CoreTests, TestNotEqualString) {
|
||||
const auto expected = "Hello from the Core!";
|
||||
auto core = std::make_unique<GenericCore>();
|
||||
const auto actual = core->toString();
|
||||
ASSERT_NE(expected, actual);
|
||||
}
|
||||
Reference in New Issue
Block a user