🔧 Replaced gtest with catch2
This commit is contained in:
@ -13,7 +13,10 @@
|
|||||||
# possible settings.
|
# possible settings.
|
||||||
#-------------------------------------------------------
|
#-------------------------------------------------------
|
||||||
cmake_minimum_required(VERSION 3.0)
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
|
||||||
project(moFileReader)
|
project(moFileReader)
|
||||||
|
|
||||||
# Let the user choose between static lib and dll
|
# Let the user choose between static lib and dll
|
||||||
|
@ -1,16 +1,13 @@
|
|||||||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
|
if(NOT EXISTS "${CMAKE_BINARY_DIR}/catch/catch.hpp")
|
||||||
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
|
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/catch")
|
||||||
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/v0.13/conan.cmake"
|
message(STATUS "Downloading catch.hpp from https://github.com/catchorg/Catch2/")
|
||||||
"${CMAKE_BINARY_DIR}/conan.cmake")
|
file(DOWNLOAD "https://github.com/catchorg/Catch2/releases/download/v2.5.0/catch.hpp"
|
||||||
|
"${CMAKE_BINARY_DIR}/catch/catch.hpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(${CMAKE_BINARY_DIR}/conan.cmake)
|
|
||||||
|
|
||||||
conan_cmake_run(REQUIRES gtest/1.8.1@bincrafters/stable BASIC_SETUP CMAKE_TARGETS BUILD missing)
|
|
||||||
|
|
||||||
add_executable(moFileReaderTest test.cpp)
|
add_executable(moFileReaderTest test.cpp)
|
||||||
target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include)
|
target_include_directories(moFileReaderTest PRIVATE ${CMAKE_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/catch)
|
||||||
target_link_libraries(moFileReaderTest CONAN_PKG::gtest moFileReader)
|
target_link_libraries(moFileReaderTest moFileReader)
|
||||||
add_test(NAME mo_test COMMAND moFileReaderTest)
|
add_test(NAME mo_test COMMAND moFileReaderTest)
|
||||||
|
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
@ -1,35 +1,36 @@
|
|||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
|
||||||
#include "moFileReader.h"
|
#include "moFileReader.h"
|
||||||
#include "gtest/gtest.h"
|
#include "catch.hpp"
|
||||||
|
|
||||||
using namespace moFileLib;
|
using namespace moFileLib;
|
||||||
#define _L(str) moFileReaderSingleton::GetInstance().Lookup(str)
|
#define _L(str) moFileReaderSingleton::GetInstance().Lookup(str)
|
||||||
#define _LC(ctx,str) moFileReaderSingleton::GetInstance().LookupWithContext(ctx,str)
|
#define _LC(ctx,str) moFileReaderSingleton::GetInstance().LookupWithContext(ctx,str)
|
||||||
|
|
||||||
TEST(moFileReader, setup)
|
TEST_CASE ("Load mo-file", "[ReadFile]")
|
||||||
{
|
{
|
||||||
EXPECT_EQ(moFileReaderSingleton::GetInstance().ReadFile("test.mo"), moFileLib::moFileReader::EC_SUCCESS);
|
CHECK (moFileReaderSingleton::GetInstance().ReadFile("test.mo") == moFileLib::moFileReader::EC_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(moFileReader, Lookup)
|
TEST_CASE ("Lookup string", "[Lookup]")
|
||||||
{
|
{
|
||||||
moFileReaderSingleton::GetInstance ().ReadFile ("test.mo");
|
moFileReaderSingleton::GetInstance ().ReadFile ("test.mo");
|
||||||
/* This is the first comment. */
|
/* This is the first comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Een", _L ("String English One"));
|
CHECK ("Text Nederlands Een" == _L ("String English One"));
|
||||||
/* This is the second comment. */
|
/* This is the second comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Twee", _L ("String English Two"));
|
CHECK ("Text Nederlands Twee" == _L ("String English Two"));
|
||||||
/* This is the third comment. */
|
/* This is the third comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Drie", _L ("String English Three"));
|
CHECK ("Text Nederlands Drie" == _L ("String English Three"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST (moFileReader, LookupWithContext)
|
TEST_CASE ("Lookup string with context", "[LookupWithContext]")
|
||||||
{
|
{
|
||||||
moFileReaderSingleton::GetInstance ().ReadFile ("test.mo");
|
moFileReaderSingleton::GetInstance ().ReadFile ("test.mo");
|
||||||
/* This is the first comment. */
|
/* This is the first comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Een", _LC ("TEST|String|1", "String English"));
|
CHECK ("Text Nederlands Een" == _LC ("TEST|String|1", "String English"));
|
||||||
/* This is the second comment. */
|
/* This is the second comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Twee", _LC ("TEST|String|2", "String English"));
|
CHECK ("Text Nederlands Twee" == _LC ("TEST|String|2", "String English"));
|
||||||
/* This is the third comment. */
|
/* This is the third comment. */
|
||||||
EXPECT_EQ ("Text Nederlands Drie", _LC ("TEST|String|3", "String English"));
|
CHECK ("Text Nederlands Drie" == _LC ("TEST|String|3", "String English"));
|
||||||
}
|
}
|
Reference in New Issue
Block a user