Private
Public Access
2
0

gtest: Added Google Test

Added Google Test for unit testing.  Currently NOT required by
MRAA CMake.

    * Added a test fixture for mraa common C header methods.
    * Added a test fixture for mraa common C++ header methods.

Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
Noel Eck
2018-03-12 10:37:56 -07:00
parent 76c8b9a76e
commit 467cf5132d
5 changed files with 210 additions and 4 deletions

28
tests/unit/CMakeLists.txt Normal file
View File

@@ -0,0 +1,28 @@
# For now, Google Test is NOT required */
find_package(GTest)
# If not found, print a status message and return
if(NOT GTEST_FOUND)
message(STATUS "Install Google Test to enable additional unit testing")
return ()
endif()
# Unit tests - C common header methods
add_executable(api_common_h_unit api/api_common_h_unit.cxx)
target_link_libraries(api_common_h_unit GTest::GTest GTest::Main mraa)
target_include_directories(api_common_h_unit
PRIVATE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/api" "${CMAKE_SOURCE_DIR}/api/mraa")
gtest_add_tests(api_common_h_unit "" AUTO)
# Unit tests - C++ common header methods
add_executable(api_common_hpp_unit api/api_common_hpp_unit.cxx)
target_link_libraries(api_common_hpp_unit GTest::GTest GTest::Main mraa)
target_include_directories(api_common_hpp_unit PRIVATE "${CMAKE_SOURCE_DIR}/api")
gtest_add_tests(api_common_hpp_unit "" AUTO)
# Add a custom target for unit tests
add_custom_target(tests-unit ALL
DEPENDS
api_common_h_unit
api_common_hpp_unit
COMMENT "mraa unit test collection")