gtest: fix version test and change test cmake var name
authorBrendan Le Foll <brendan.le.foll@intel.com>
Tue, 20 May 2014 14:40:28 +0000 (15:40 +0100)
committerBrendan Le Foll <brendan.le.foll@intel.com>
Tue, 20 May 2014 14:40:28 +0000 (15:40 +0100)
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
CMakeLists.txt
tests/CMakeLists.txt
tests/maa_test.cxx

index 6888305..57d8aed 100644 (file)
@@ -37,7 +37,7 @@ set (maa_VERSION_STRING ${maa_VERSION_MAJOR}.${maa_VERSION_MINOR}.${maa_VERSION_
 
 set (CMAKE_SWIG_FLAGS "")
 
-option (test "Build all tests." OFF)
+option (GTEST "Build all gtests." OFF)
 
 if (test)
   enable_testing ()
index 48abce6..ebe9ba3 100644 (file)
@@ -1,11 +1,15 @@
 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})
+include_directories(
+  ${GTEST_INCLUDE_DIRS}
+  ${PROJECT_SOURCE_DIR}/api
+  ${PROJECT_SOURCE_DIR}/include
+)
 
 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})
index aeb32e9..f610389 100644 (file)
@@ -1,8 +1,12 @@
-#include "maa.h"
+#include <maa.h>
 #include "gtest/gtest.h"
+#include "version.h"
 
-using namespace maa;
-
-TEST (basic, GetVersion) {
-    ASSERT_EQ(get_version(), 1);
+/* Careful, this test will only attempt to check the returned version is valid,
+ * it doesn't try to check the version is a release one.
+ */
+TEST (basic, maa_get_version) {
+    char bar[64];
+    strcpy(bar, maa_get_version());
+    ASSERT_STREQ(maa_get_version(), gVERSION);
 }