From 8b715745fcc8cc792c2723d9f4bbc41cc400a553 Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 10 Apr 2014 11:07:05 +0100 Subject: [PATCH] tests: add initial unit test env --- CMakeLists.txt | 9 ++++++++- README | 5 +++++ tests/CMakeLists.txt | 11 +++++++++++ tests/maa_test.cxx | 8 ++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/maa_test.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index adfd8c7..5c5cd38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 2.8) project (maa) set(SWIG_EXECUTABLE /usr/bin/swig) @@ -7,6 +7,13 @@ INCLUDE(${SWIG_USE_FILE}) SET(CMAKE_SWIG_FLAGS "") +option(test "Build all tests." OFF) + add_subdirectory (src) add_subdirectory (api) add_subdirectory (examples) + +if (test) + enable_testing () + add_subdirectory (tests) +endif() diff --git a/README b/README index 08fa377..2fa2b87 100644 --- a/README +++ b/README @@ -32,6 +32,11 @@ make Install is currently unsuported. Javascript and python modules will be in build/src/{javascript, python} +=== DEVELOPMENT === + +Unit tests for all features must be completed prior to implementations, please +run `ctest -V` from the build dir in order to see current implementation status + === USING === see examples/ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..48abce6 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +find_package (GTest REQUIRED) + +set(PROJECT_TEST_NAME "${PROJECT_NAME}_test") +set(COMMON_INCLUDES ${PROJECT_SOURCE_DIR}/src) + +include_directories(${GTEST_INCLUDE_DIRS} ${COMMON_INCLUDES}) + +add_executable(${PROJECT_TEST_NAME} "maa_test.cxx") +target_link_libraries(${PROJECT_TEST_NAME} ${PROJECT_NAME_STR} ${GTEST_BOTH_LIBRARIES} maa pthread) + +add_test(Basic ${PROJECT_TEST_NAME}) diff --git a/tests/maa_test.cxx b/tests/maa_test.cxx new file mode 100644 index 0000000..aeb32e9 --- /dev/null +++ b/tests/maa_test.cxx @@ -0,0 +1,8 @@ +#include "maa.h" +#include "gtest/gtest.h" + +using namespace maa; + +TEST (basic, GetVersion) { + ASSERT_EQ(get_version(), 1); +} -- 2.7.4