summaryrefslogtreecommitdiffstats
path: root/src/common/test
diff options
context:
space:
mode:
authorPiotr Dziwinski <piotrdz@gmail.com>2013-02-03 20:03:36 +0100
committerPiotr Dziwinski <piotrdz@gmail.com>2013-02-03 20:03:36 +0100
commit209c6412ae149cc7c503fd7da384f344a830423c (patch)
tree5baeaeb8dee2208b46bf80a118dfe59eb65f9389 /src/common/test
parent3f41f97fc47fca22634dc858c3ecdb39d0d27e32 (diff)
downloadcolobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.gz
colobot-209c6412ae149cc7c503fd7da384f344a830423c.tar.bz2
colobot-209c6412ae149cc7c503fd7da384f344a830423c.zip
Refactoring in tests infrastructure
* all tests are now in /test/ subdirectory * unit tests concatenated to one executable (TODO: ui, common) * preparation for test environments (OpenGL and others) * removed old TestCBot
Diffstat (limited to 'src/common/test')
-rw-r--r--src/common/test/CMakeLists.txt22
-rw-r--r--src/common/test/colobot.ini15
-rw-r--r--src/common/test/image_test.cpp57
-rw-r--r--src/common/test/profile_test.cpp44
4 files changed, 0 insertions, 138 deletions
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
deleted file mode 100644
index 70dac1f..0000000
--- a/src/common/test/CMakeLists.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-cmake_minimum_required(VERSION 2.8)
-
-if(NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE debug)
-endif(NOT CMAKE_BUILD_TYPE)
-set(CMAKE_CXX_FLAGS_DEBUG "-g -O0")
-
-include_directories(
-.
-../..
-../../..
-${GTEST_INCLUDE_DIR}
-)
-
-
-add_executable(image_test ../image.cpp image_test.cpp)
-target_link_libraries(image_test ${SDL_LIBRARY} ${SDLIMAGE_LIBRARY} ${PNG_LIBRARIES})
-
-#add_executable(profile_test ../profile.cpp ../logger.cpp profile_test.cpp)
-#target_link_libraries(profile_test gtest ${Boost_LIBRARIES})
-
-#add_test(profile_test ./profile_test)
diff --git a/src/common/test/colobot.ini b/src/common/test/colobot.ini
deleted file mode 100644
index 2ca37ee..0000000
--- a/src/common/test/colobot.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[test_float]
-float_value=1.5
-
-[test_string]
-string_value=Hello world
-
-[test_int]
-int_value=42
-
-[test_multi]
-entry1=1
-entry2=2
-entry3=3
-entry4=4
-entry5=5
diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp
deleted file mode 100644
index 09ae4c6..0000000
--- a/src/common/test/image_test.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-#include "../image.h"
-
-#include <SDL/SDL.h>
-#include <stdio.h>
-
-/* For now, just a simple test: loading a file from image
- * and saving it to another in PNG. */
-
-int main(int argc, char *argv[])
-{
- if (argc != 3)
- {
- printf("Usage: %s in_image out_image\n", argv[0]);
- return 0;
- }
-
- CImage image;
-
- if (! image.Load(argv[1]))
- {
- std::string err = image.GetError();
- printf("Error loading '%s': %s\n", argv[1], err.c_str());
- return 1;
- }
- Gfx::Color color;
- std::string str;
-
- color = image.GetPixel(Math::IntPoint(0, 0));
- str = color.ToString();
- printf("pixel @ (0,0): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(0, 1));
- str = color.ToString();
- printf("pixel @ (0,1): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(1, 0));
- str = color.ToString();
- printf("pixel @ (1,0): %s\n", str.c_str());
-
- color = image.GetPixel(Math::IntPoint(1, 1));
- str = color.ToString();
- printf("pixel @ (1,1): %s\n", str.c_str());
-
- image.SetPixel(Math::IntPoint(0, 0), Gfx::Color(0.1f, 0.2f, 0.3f, 0.0f));
- image.SetPixel(Math::IntPoint(1, 0), Gfx::Color(0.3f, 0.2f, 0.1f, 1.0f));
- image.SetPixel(Math::IntPoint(0, 1), Gfx::Color(1.0f, 1.0f, 1.0f, 1.0f));
- image.SetPixel(Math::IntPoint(1, 1), Gfx::Color(0.0f, 0.0f, 0.0f, 1.0f));
-
- if (! image.SavePNG(argv[2]))
- {
- std::string err = image.GetError();
- printf("Error saving PNG '%s': %s\n", argv[2], err.c_str());
- return 2;
- }
-
- return 0;
-}
diff --git a/src/common/test/profile_test.cpp b/src/common/test/profile_test.cpp
deleted file mode 100644
index 6236083..0000000
--- a/src/common/test/profile_test.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "../profile.h"
-#include "../logger.h"
-
-#include <iostream>
-#include <string>
-#include <vector>
-#include <gtest/gtest.h>
-
-
-class CProfileTest : public testing::Test
-{
-protected:
- CLogger m_logger;
- CProfile m_profile;
-
-};
-
-TEST_F(CProfileTest, ReadTest)
-{
- ASSERT_TRUE(m_profile.InitCurrentDirectory()); // load colobot.ini file
-
- std::string result;
- ASSERT_TRUE(m_profile.GetLocalProfileString("test_string", "string_value", result));
- ASSERT_STREQ("Hello world", result.c_str());
-
- int int_value;
- ASSERT_TRUE(m_profile.GetLocalProfileInt("test_int", "int_value", int_value));
- ASSERT_EQ(42, int_value);
-
- float float_value;
- ASSERT_TRUE(m_profile.GetLocalProfileFloat("test_float", "float_value", float_value));
- ASSERT_FLOAT_EQ(1.5, float_value);
-
- std::vector<std::string> list;
- list = m_profile.GetLocalProfileSection("test_multi", "entry");
- ASSERT_EQ(5u, list.size());
-}
-
-int main(int argc, char *argv[])
-{
- ::testing::InitGoogleTest(&argc, argv);
- return RUN_ALL_TESTS();
-}
-