From: Jannik ZANDER Date: Thu, 9 Feb 2017 21:19:44 +0000 (+0100) Subject: Initial commit X-Git-Url: https://git.zndr.dk/?a=commitdiff_plain;h=f6757f9b8a2f9abd33efd0426d2cc04d90947134;p=unittest.git Initial commit --- f6757f9b8a2f9abd33efd0426d2cc04d90947134 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6cd80db --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +; Top level editor config +root = true +; Always use Unix style new lines +end_of_line = lf +; New line ending on every file +insert_final_newline = true +; Trim whitespace +trim_trailing_whitespace = true +[*.py] +; PEP8 defines 4 spaces for indentation +indent_style = space +indent_size = 4 +[*.md] +; Markup file 2 spaces for indentation +indent_style = space +indent_size = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +* diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..45d8546 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required (VERSION 3.2) +project(solution_test) + +set(USE_GTEST "yes") + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +find_package(AddUnitTest) + +# Add folder1 +add_subdirectory(folder1/Source) +add_subdirectory(folder1/Test) + +# Add folder2 +add_subdirectory(folder2/Source) +add_subdirectory(folder2/Test) + diff --git a/README.md b/README.md new file mode 100644 index 0000000..f38fe4a --- /dev/null +++ b/README.md @@ -0,0 +1,203 @@ +# Unit testing with CMake + +This is a framework for doing unit testing with CMake. + +Content +* [Setup steps for Windows](#setup) +* [Usage](#usage) +* [Demo](#demo) + + +## Setup steps for Windows +* Install Visual Studio 2008 +* Install CMake + * Make sure executable is added to environmant path. +* Install CPPUnit + * Make sure the environment variable CPPUNITDIR is pointing to your installation folder. + * Make sure CPPUnit is compiled with same compiler as is used to testing (MSVC 2008) + +Some additional notes +* Visual Studio 2013 can also be used (or any other C++ compiler that is installed on your PC) +* The framework support both CPPUnit testing framework and google testing framework +* If google testing framework is selected it will be git cloned automatically if it is not found on your PC. This has the added advantages: + * Easy to swap between compilers since it is build automatically + * No installation of testing framework is required beforehand + + +## Usage +To setup testing you need to define a "unit" of code that shall be tested and a corresponding "unittest". + +Each "unit" of code has a name and the following properties: +* What source files should be included in this "unit" +* Which public interface or include path we need for this "unit" +* Which other "units" this "unit" depends on + +A "unittest" of code has the same kind of properties. + +Each user of a "unit" can be kept unaware of that +* You decide to re-arrange your "unit" e.g split a .c file pair into two file pairs +* You add/remove dependencies to other "units" + +Unit tests should only test the public interface of the "unit" and never access private parts + +To describe this for CMake a file called "CMakeLists.txt" should be created each folder that contain a "unit" of code. +A function call to either "add_unit()" or "add_unittest()" is added to the file. + +Example of a "unit": + + $ add_unit(TARGET folder1 + $ SRCS folder1.c + $ INCS .) + +Example of another "unit" depending on the first "unit": + + $ add_unit(TARGET folder2 + $ SRCS folder2.c + $ INCS . + $ DEPS folder1) + +Example of "unittest": + + $ add_unittest(TARGET folder2_test + $ SRCS folder2_test.cpp + $ INCS . + $ DEPS folder2) + + +## Demo + $ mkdir build + $ cd build + $ cmake -GNinja .. + $ -- The C compiler identification is GNU 6.2.0 + $ -- The CXX compiler identification is GNU 6.2.0 + $ -- Check for working C compiler: C:/programs/msys64/mingw64/bin/cc.exe + $ -- Check for working C compiler: C:/programs/msys64/mingw64/bin/cc.exe -- works + $ -- Detecting C compiler ABI info + $ -- Detecting C compiler ABI info - done + $ -- Detecting C compile features + $ -- Detecting C compile features - done + $ -- Check for working CXX compiler: C:/programs/msys64/mingw64/bin/c++.exe + $ -- Check for working CXX compiler: C:/programs/msys64/mingw64/bin/c++.exe -- works + $ -- Detecting CXX compiler ABI info + $ -- Detecting CXX compiler ABI info - done + $ -- Detecting CXX compile features + $ -- Detecting CXX compile features - done + $ -- Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR GTEST_MAIN_LIBRARY) + $ -- Found Git: C:/programs/msys64/usr/bin/git.exe (found version "2.9.0") + $ -- Configuring done + $ -- Generating done + $ -- Build files have been written to: C:/Projects/repos/jannikz/unittest_cmake/build/googletest-download + $ [1/9] Creating directories for 'googletest' + $ [2/9] Performing download step (git clone) for 'googletest' + $ Cloning into 'googletest-src'... + $ Already on 'master' + $ Your branch is up-to-date with 'origin/master'. + $ [3/9] No patch step for 'googletest' + $ [4/9] Performing update step for 'googletest' + $ Current branch master is up to date. + $ [5/9] No configure step for 'googletest' + $ [6/9] No build step for 'googletest' + $ [7/9] No install step for 'googletest' + $ [8/9] No test step for 'googletest' + $ [9/9] Completed 'googletest' + $ -- Found PythonInterp: C:/programs/msys64/mingw64/bin/python.exe (found version "2.7.11") + $ =================================================== + $ Component: + $ folder1: + $ Sources: + $ - folder1.c + $ Includes: + $ - . + $ Dependencies: + $ Definitions: + $ =================================================== + $ Component: + $ folder1_if: + $ Sources: + $ Includes: + $ - . + $ Dependencies: + $ Definitions: + $ =================================================== + $ UnitTest: + $ folder1_test: + $ Sources: + $ - folder1_test.cpp + $ Includes: + $ - . + $ Dependencies: + $ - folder1 + $ Definitions: + $ =================================================== + $ Component: + $ folder2: + $ Sources: + $ - folder2.c + $ Includes: + $ - . + $ Dependencies: + $ - folder1 + $ Definitions: + $ =================================================== + $ UnitTest: + $ folder2_test: + $ Sources: + $ - folder2_test.cpp + $ Includes: + $ - . + $ Dependencies: + $ - folder2 + $ Definitions: + $ =================================================== + $ -- Configuring done + $ -- Generating done + $ -- Build files have been written to: C:/Projects/repos/jannikz/unittest_cmake/build + $ cmake --build . + $ [1/19] Building C object folder1/Source/CMakeFiles/folder1.dir/folder1.c.obj + $ [2/19] Linking C static library folder1\Source\libfolder1.a + $ [3/19] Building C object folder2/Source/CMakeFiles/folder2.dir/folder2.c.obj + $ [4/19] Linking C static library folder2\Source\libfolder2.a + $ [5/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.obj + $ [6/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.obj + $ [7/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.obj + $ [8/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.obj + $ [9/19] Building CXX object googletest-build/googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.obj + $ [10/19] Building CXX object googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj + $ [11/19] Linking CXX static library googletest-build\googlemock\gtest\libgtest.a + $ [12/19] Linking CXX static library googletest-build\googlemock\libgmock.a + $ [13/19] Linking CXX static library googletest-build\googlemock\libgmock_main.a + $ [14/19] Building CXX object googletest-build/googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.obj + $ [15/19] Linking CXX static library googletest-build\googlemock\gtest\libgtest_main.a + $ [16/19] Building CXX object folder2/Test/CMakeFiles/folder2_test.dir/folder2_test.cpp.obj + $ [17/19] Building CXX object folder1/Test/CMakeFiles/folder1_test.dir/folder1_test.cpp.obj + $ [18/19] Linking CXX executable folder2\Test\folder2_test.exe + $ Running main() from gtest_main.cc + $ [==========] Running 1 test from 1 test case. + $ [----------] Global test environment set-up. + $ [----------] 1 test from function3_test + $ [ RUN ] function3_test.compare3 + $ [ OK ] function3_test.compare3 (0 ms) + $ [----------] 1 test from function3_test (0 ms total) + $ + $ [----------] Global test environment tear-down + $ [==========] 1 test from 1 test case ran. (0 ms total) + $ [ PASSED ] 1 test. + $ [19/19] Linking CXX executable folder1\Test\folder1_test.exe + $ Running main() from gtest_main.cc + $ [==========] Running 2 tests from 2 test cases. + $ [----------] Global test environment set-up. + $ [----------] 1 test from function1_test + $ [ RUN ] function1_test.compare1 + $ [ OK ] function1_test.compare1 (0 ms) + $ [----------] 1 test from function1_test (0 ms total) + $ + $ [----------] 1 test from function2_test + $ [ RUN ] function2_test.compare2 + $ [ OK ] function2_test.compare2 (0 ms) + $ [----------] 1 test from function2_test (0 ms total) + $ + $ [----------] Global test environment tear-down + $ [==========] 2 tests from 2 test cases ran. (0 ms total) + $ [ PASSED ] 2 tests. + + diff --git a/cmake/CMakeLists.txt.in b/cmake/CMakeLists.txt.in new file mode 100644 index 0000000..73ea4a6 --- /dev/null +++ b/cmake/CMakeLists.txt.in @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.2) + +project(googletest-download NONE) + +include(ExternalProject) +ExternalProject_Add(googletest + GIT_REPOSITORY https://github.com/google/googletest.git + GIT_TAG master + SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" + BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) + diff --git a/cmake/FindAddUnitTest.cmake b/cmake/FindAddUnitTest.cmake new file mode 100644 index 0000000..0a69117 --- /dev/null +++ b/cmake/FindAddUnitTest.cmake @@ -0,0 +1,150 @@ +cmake_minimum_required (VERSION 3.2) + +enable_testing() +set_property( GLOBAL PROPERTY USE_FOLDERS ON) + +################################ +# Add unit function +################################ +function(add_unit) + cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN}) + print_target("Component" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}") + if ("${my_SRCS}" MATCHES ".*\\.(cpp|c)") + # Add public library + add_library(${my_TARGET} "${my_SRCS}") + foreach(inc ${my_INCS}) + target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}") + endforeach() + target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}") + target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS}) + add_unitfolder(${my_TARGET} "${my_SRCS}") + else() + # Add interface library + add_library(${my_TARGET} INTERFACE) + foreach(inc ${my_INCS}) + target_include_directories(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${inc}") + endforeach() + target_link_libraries(${my_TARGET} INTERFACE "${my_DEPS}") + target_compile_definitions(${my_TARGET} INTERFACE ${my_DEFS}) + + # Add header files to IDE view (this has no effect on build) + foreach(src ${my_SRCS}) + target_sources(${my_TARGET} INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/${src}") + endforeach() + endif() +endfunction() + +################################ +# Add unittest function +################################ +function(add_unittest) + cmake_parse_arguments(my "" "TARGET" "INCS;SRCS;DEPS;DEFS" ${ARGN}) + print_target("UnitTest" "${my_TARGET}" "${my_SRCS}" "${my_INCS}" "${my_DEPS}" "${my_DEFS}") + + # Add test executable + add_executable(${my_TARGET} "${my_SRCS}") + foreach(inc ${my_INCS}) + target_include_directories(${my_TARGET} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${inc}") + endforeach() + if (USE_GTEST) + if(GTEST_FOUND) + target_include_directories(${my_TARGET} PUBLIC "${GTEST_INCLUDE_DIRS}") + target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" ${GTEST_BOTH_LIBRARIES}) + else() + target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" gtest gtest_main) + endif() + target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS} USE_GTEST) + else() + target_include_directories(${my_TARGET} PUBLIC "${CPPUNIT_INCLUDE_DIRS}") + target_link_libraries(${my_TARGET} PUBLIC "${my_DEPS}" ${CPPUNIT_LIBRARIES}) + target_compile_definitions(${my_TARGET} PUBLIC ${my_DEFS}) + endif() + # Add test to test suite + add_test(${my_TARGET} ${my_TARGET}) + add_unitfolder(${my_TARGET} "${my_SRCS}") + # Run test after build + add_custom_command(TARGET ${my_TARGET} POST_BUILD COMMAND ${my_TARGET}) +endfunction() + +################################ +# Add add_unitfolder function (only for IDE) +################################ +function(add_unitfolder mytarget mysrcs) + # source_group("" FILES "${mysrcs}") + string(REGEX REPLACE "_stub*$" "" myfolder ${mytarget}) + string(REGEX REPLACE "_stubs*$" "" myfolder ${mytarget}) + string(REGEX REPLACE "_test*$" "" myfolder ${myfolder}) + string(REGEX REPLACE "_if*$" "" myfolder ${myfolder}) + string(TOUPPER ${myfolder} myfolder) + set_property(TARGET ${mytarget} PROPERTY FOLDER "${myfolder}") +endfunction() + +################################ +# Print target function +################################ +function(print_target type target srcs incs deps defs) + message("${type}:") + message(" ${target}:") + message(" Sources:") + foreach(src ${srcs}) + message(" - ${src}") + endforeach() + message(" Includes:") + foreach(inc ${incs}) + message(" - ${inc}") + endforeach() + message(" Dependencies:") + foreach(dep ${deps}) + message(" - ${dep}") + endforeach() + message(" Definitions:") + foreach(def ${defs}) + message(" - ${def}") + endforeach() + message("===================================================") +endfunction() + + +################################ +# Compiler options +################################ +if(MSVC) + add_definitions(/FC /D_CRT_SECURE_NO_WARNINGS) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX) + add_definitions(-Wall -Wno-deprecated -pthread -D__PC__) +endif() + +################################ +# Configure testing framework +################################ + +if(USE_GTEST) + if(NOT GTEST_ROOT) + if(NOT $ENV{GTEST_DIR} STREQUAL "") + set(GTEST_ROOT "$ENV{GTEST_DIR}") + else() + set(GTEST_ROOT "C:/googletest-release-1.7.0") + endif() + endif() + + find_package(gtest) + if(NOT GTEST_FOUND) + # Add external google test project + find_package(git REQUIRED) + include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/gtest.cmake") + endif() +else() + if(NOT CPPUNIT_ROOT_DIR) + if(NOT $ENV{CPPUNITDIR} STREQUAL "") + set(CPPUNIT_ROOT_DIR "$ENV{CPPUNITDIR}/lib") + else() + set(CPPUNIT_ROOT_DIR "C:/cppunit-1.12.1/lib") + endif() + endif() + + find_package(cppunit REQUIRED) +endif() + +message("===================================================") diff --git a/cmake/Findcppunit.cmake b/cmake/Findcppunit.cmake new file mode 100644 index 0000000..b83b67e --- /dev/null +++ b/cmake/Findcppunit.cmake @@ -0,0 +1,76 @@ +# - try to find cppunit library +# +# Cache Variables: (probably not for direct use in your scripts) +# CPPUNIT_INCLUDE_DIR +# CPPUNIT_LIBRARY +# +# Non-cache variables you might use in your CMakeLists.txt: +# CPPUNIT_FOUND +# CPPUNIT_INCLUDE_DIRS +# CPPUNIT_LIBRARIES +# +# Requires these CMake modules: +# SelectLibraryConfigurations (included with CMake >= 2.8.0) +# FindPackageHandleStandardArgs (known included with CMake >=2.6.2) +# +# Original Author: +# 2009-2011 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2011. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(CPPUNIT_ROOT_DIR + "${CPPUNIT_ROOT_DIR}" + CACHE + PATH + "Directory to search") + +find_library(CPPUNIT_LIBRARY_RELEASE + NAMES + cppunit + HINTS + "${CPPUNIT_ROOT_DIR}") + +find_library(CPPUNIT_LIBRARY_DEBUG + NAMES + cppunitd + HINTS + "${CPPUNIT_ROOT_DIR}") + +include(SelectLibraryConfigurations) +select_library_configurations(CPPUNIT) + +# Might want to look close to the library first for the includes. +get_filename_component(_libdir "${CPPUNIT_LIBRARY_RELEASE}" PATH) + +find_path(CPPUNIT_INCLUDE_DIR + NAMES + cppunit/TestCase.h + HINTS + "${_libdir}/.." + PATHS + "${CPPUNIT_ROOT_DIR}" + PATH_SUFFIXES + include/) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(cppunit + DEFAULT_MSG + CPPUNIT_LIBRARY + CPPUNIT_INCLUDE_DIR) + +if(CPPUNIT_FOUND) + set(CPPUNIT_LIBRARIES ${CPPUNIT_LIBRARY} ${CMAKE_DL_LIBS}) + set(CPPUNIT_INCLUDE_DIRS "${CPPUNIT_INCLUDE_DIR}") + mark_as_advanced(CPPUNIT_ROOT_DIR) +endif() + +mark_as_advanced(CPPUNIT_INCLUDE_DIR + CPPUNIT_LIBRARY_RELEASE + CPPUNIT_LIBRARY_DEBUG) + diff --git a/cmake/gtest.cmake b/cmake/gtest.cmake new file mode 100644 index 0000000..5c92fde --- /dev/null +++ b/cmake/gtest.cmake @@ -0,0 +1,34 @@ +cmake_minimum_required (VERSION 3.2) + +find_path (my_PATH NAMES CMakeLists.txt.in HINTS ${CMAKE_MODULE_PATH}) + +# Download and unpack googletest at configure time +configure_file("${my_PATH}/CMakeLists.txt.in" googletest-download/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") +endif() +execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) +if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") +endif() + +# Prevent overriding the parent project's compiler/linker +# settings on Windows +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +# Add googletest directly to our build. This defines +# the gtest and gtest_main targets. +add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src + ${CMAKE_BINARY_DIR}/googletest-build) + +# The gtest/gtest_main targets carry header search path +# dependencies automatically when using CMake 2.8.11 or +# later. Otherwise we have to add them here ourselves. +if (CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories("${gtest_SOURCE_DIR}/include") +endif() diff --git a/folder1/Source/CMakeLists.txt b/folder1/Source/CMakeLists.txt new file mode 100644 index 0000000..624047b --- /dev/null +++ b/folder1/Source/CMakeLists.txt @@ -0,0 +1,7 @@ +add_unit(TARGET folder1 + SRCS folder1.c + INCS .) + +add_unit(TARGET folder1_if + INCS .) + diff --git a/folder1/Source/folder1.c b/folder1/Source/folder1.c new file mode 100644 index 0000000..36066c0 --- /dev/null +++ b/folder1/Source/folder1.c @@ -0,0 +1,11 @@ +#include "folder1.h" + +int function1() +{ + return 1; +} + +int function2() +{ + return 2; +} \ No newline at end of file diff --git a/folder1/Source/folder1.h b/folder1/Source/folder1.h new file mode 100644 index 0000000..ae3e5bd --- /dev/null +++ b/folder1/Source/folder1.h @@ -0,0 +1,7 @@ +#ifndef FOLDER1_H +#define FOLDER1_H + +int function1(); +int function2(); + +#endif // FOLDER1_H \ No newline at end of file diff --git a/folder1/Test/CMakeLists.txt b/folder1/Test/CMakeLists.txt new file mode 100644 index 0000000..d5572c6 --- /dev/null +++ b/folder1/Test/CMakeLists.txt @@ -0,0 +1,4 @@ +add_unittest(TARGET folder1_test + SRCS folder1_test.cpp + INCS . + DEPS folder1) diff --git a/folder1/Test/folder1_test.cpp b/folder1/Test/folder1_test.cpp new file mode 100644 index 0000000..68d7673 --- /dev/null +++ b/folder1/Test/folder1_test.cpp @@ -0,0 +1,15 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder1.h" +} + +TEST(function1_test, compare1) +{ + ASSERT_EQ(function1(), 1) << "Values are equal function1 == 1"; +} + +TEST(function2_test, compare2) +{ + ASSERT_EQ(function2(), 2) << "Values are equal function2 == 2"; +} + diff --git a/folder2/Source/CMakeLists.txt b/folder2/Source/CMakeLists.txt new file mode 100644 index 0000000..b509ca4 --- /dev/null +++ b/folder2/Source/CMakeLists.txt @@ -0,0 +1,5 @@ +add_unit(TARGET folder2 + SRCS folder2.c + INCS . + DEPS folder1) + diff --git a/folder2/Source/folder2.c b/folder2/Source/folder2.c new file mode 100644 index 0000000..2d27b97 --- /dev/null +++ b/folder2/Source/folder2.c @@ -0,0 +1,8 @@ +#include "folder1.h" +#include "folder2.h" + + +int function3() +{ + return function1()+function2(); +} diff --git a/folder2/Source/folder2.h b/folder2/Source/folder2.h new file mode 100644 index 0000000..b03ea51 --- /dev/null +++ b/folder2/Source/folder2.h @@ -0,0 +1,6 @@ +#ifndef FOLDER2_H +#define FOLDER2_H + +int function3(); + +#endif // FOLDER2_H \ No newline at end of file diff --git a/folder2/Test/CMakeLists.txt b/folder2/Test/CMakeLists.txt new file mode 100644 index 0000000..a03731c --- /dev/null +++ b/folder2/Test/CMakeLists.txt @@ -0,0 +1,5 @@ +add_unittest(TARGET folder2_test + SRCS folder2_test.cpp + INCS . + DEPS folder2) + diff --git a/folder2/Test/folder2_test.cpp b/folder2/Test/folder2_test.cpp new file mode 100644 index 0000000..6e0d942 --- /dev/null +++ b/folder2/Test/folder2_test.cpp @@ -0,0 +1,9 @@ +#include "gtest/gtest.h" +extern "C" { +#include "folder2.h" +} + +TEST(function3_test, compare3) +{ + ASSERT_EQ(function3(), 3) << "Values are equal function3 == 3"; +}