Commit 6d3a8f62 authored by msafroshkin's avatar msafroshkin
Browse files

added a very simple GTest Example

parent 6964789c
......@@ -2,7 +2,11 @@ cmake_minimum_required(VERSION 3.8)
#including macroses
include(cmake/SetBoostEnv.cmake)
include(cmake/SetNlohmannEnv.cmake)
include(cmake/SetGTest.cmake)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/aruco)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/OSLabDetector)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ccalib)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/ccalibTool)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tst_src)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/tst)
include ( $ENV{PREPARE_ENV_DIR}/googleTest/lib/cmake/GTest/GTestConfig.cmake)
\ No newline at end of file
set(TARGET TestExample_test)
file(GLOB_RECURSE TEST_SOURCES LIST_DIRECTORIES false *.h *.cpp)
set(SOURCES ${TEST_SOURCES})
add_executable(${TARGET} ${TEST_SOURCES})
add_test(NAME ${TARGET} COMMAND ${TARGET})
set(GTEST_ROOT $ENV{PREPARE_ENV_DIR}/googleTest )
find_package(GTest REQUIRED)
target_include_directories (${TARGET} PRIVATE ${GTEST_INCLUDE_DIR})
target_include_directories (${TARGET} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../tst_src)
target_link_libraries(${TARGET} TestSource_lib ${GTEST_BOTH_LIBRARIES})
\ No newline at end of file
#include "gtest/gtest.h"
#include "Formula.h"
TEST(blaTest, test1) {
//arrange
//act
//assert
EXPECT_EQ (Formula::bla (0), 0);
EXPECT_EQ (Formula::bla (10), 20);
EXPECT_EQ (Formula::bla (50), 100);
}
\ No newline at end of file
#include "gtest/gtest.h"
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
\ No newline at end of file
set(TARGET TestSource)
file(GLOB_RECURSE SOURCES LIST_DIRECTORIES true *.h *.cpp)
set(SOURCES ${SOURCES})
add_executable(${TARGET}_run ${SOURCES})
add_library(${TARGET}_lib STATIC ${SOURCES})
set(${TARGET}_lib ${TARGET}_lib PARENT_SCOPE)
#include "Formula.h"
int Formula::bla(int arg1) {
return arg1 * 2;
}
\ No newline at end of file
#ifndef EXAMPLEPROJECT_FORMULA_H
#define EXAMPLEPROJECT_FORMULA_H
class Formula {
public:
static int bla(int arg1);
};
#endif //EXAMPLEPROJECT_FORMULA_H
\ No newline at end of file
#include <iostream>
#include "Formula.h"
int main() {
std::cout << "Bla: " << Formula::bla(2) << std::endl;
return 0;
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment