Ver Fonte

Add ctest support

Daniele Bartolini há 12 anos atrás
pai
commit
7803562620
3 ficheiros alterados com 21 adições e 9 exclusões
  1. 1 1
      CMakeLists.txt
  2. 10 1
      tests/CMakeLists.txt
  3. 10 7
      tests/containers.cpp

+ 1 - 1
CMakeLists.txt

@@ -11,7 +11,7 @@ option (CROWN_BUILD_OPENGL "Whether to build the OpenGL renderer or not." ON)
 option (CROWN_BUILD_OPENGLES "Whether to build the OpenGL|ES 1.0 renderer or not." OFF)
 option (CROWN_BUILD_SAMPLES "Whether to build the samples" ON)
 option (CROWN_BUILD_TOOLS "Whether to build the tools" ON)
-option (CROWN_BUILD_TESTS "Whether to build unit tests" OFF)
+option (CROWN_BUILD_TESTS "Whether to build unit tests" ON)
 
 set (INCLUDES
 	${CMAKE_SOURCE_DIR}/src

+ 10 - 1
tests/CMakeLists.txt

@@ -4,6 +4,8 @@ project(crown-tests)
 
 link_directories(${CROWN_BINARY_DIR})
 
+enable_testing()
+
 add_executable(allocators allocators.cpp)
 add_executable(containers containers.cpp)
 add_executable(messages messages.cpp)
@@ -12,7 +14,6 @@ add_executable(connections connections.cpp)
 add_executable(strings strings.cpp)
 add_executable(paths paths.cpp)
 
-
 target_link_libraries(allocators crown)
 target_link_libraries(containers crown)
 target_link_libraries(messages crown)
@@ -20,3 +21,11 @@ target_link_libraries(compressors crown)
 target_link_libraries(connections crown)
 target_link_libraries(strings crown)
 target_link_libraries(paths crown)
+
+add_test(allocators-test ${EXECUTABLE_OUTPUT_PATH}/allocators)
+add_test(containers-test containers)
+add_test(messages-test messages)
+add_test(compressors-test compressors)
+add_test(connections-test connections)
+add_test(strings-test strings)
+add_test(paths-test paths)

+ 10 - 7
tests/containers.cpp

@@ -1,5 +1,4 @@
-#include "List.h"
-#include "Array.h"
+#include "Crown.h"
 #include <cstdio>
 #include <cassert>
 
@@ -7,7 +6,9 @@ using namespace crown;
 
 int main()
 {
-	List<int> int_list;
+	MallocAllocator allocator;
+
+	List<int> int_list(allocator);
 
 	assert(int_list.size() == 0);
 
@@ -19,17 +20,19 @@ int main()
 	int_list.push_back(60);
 
 	assert(int_list.size() == 6);
-	assert(*int_list.begin() == 10);
-	assert(*int_list.end() == 60);
+	assert(int_list.front() == 10);
+	assert(int_list.back() == 60);
 
 	int_list.pop_back();
 
 	assert(int_list.size() == 5);
-	assert(*int_list.begin() == 10);
-	assert(*int_list.end() == 50);
+	assert(int_list.front() == 10);
+	assert(int_list.back() == 50);
 
 	int_list.clear();
 
 	assert(int_list.size() == 0);
+
+	return 0;
 }