summaryrefslogtreecommitdiffstats
path: root/src/common/test
diff options
context:
space:
mode:
authorerihel <erihel@gmail.com>2012-08-09 20:20:47 +0200
committererihel <erihel@gmail.com>2012-08-09 20:20:47 +0200
commit611680a72e0f04e080c3b7ed59bd23d5b8b709f1 (patch)
treee27ba7ba84de26777d275969993d46d904eb37e7 /src/common/test
parentd56db5f4e4a8e0d572bf3d682619bb25aebe4120 (diff)
parentbc24b9f9e516e657fcc0034808e010287fc2e393 (diff)
downloadcolobot-611680a72e0f04e080c3b7ed59bd23d5b8b709f1.tar.gz
colobot-611680a72e0f04e080c3b7ed59bd23d5b8b709f1.tar.bz2
colobot-611680a72e0f04e080c3b7ed59bd23d5b8b709f1.zip
Merge branch 'dev' of https://github.com/adiblol/colobot into dev
Conflicts: src/sound/sound.h
Diffstat (limited to 'src/common/test')
-rw-r--r--src/common/test/CMakeLists.txt6
-rw-r--r--src/common/test/image_test.cpp34
2 files changed, 40 insertions, 0 deletions
diff --git a/src/common/test/CMakeLists.txt b/src/common/test/CMakeLists.txt
new file mode 100644
index 0000000..680116c
--- /dev/null
+++ b/src/common/test/CMakeLists.txt
@@ -0,0 +1,6 @@
+cmake_minimum_required(VERSION 2.8)
+
+set(CMAKE_BUILD_TYPE debug)
+set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g -O0")
+
+add_executable(image_test ../image.cpp image_test.cpp)
diff --git a/src/common/test/image_test.cpp b/src/common/test/image_test.cpp
new file mode 100644
index 0000000..0ad1ee2
--- /dev/null
+++ b/src/common/test/image_test.cpp
@@ -0,0 +1,34 @@
+#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", err.c_str());
+ return 1;
+ }
+
+ if (! image.SavePNG(argv[2]))
+ {
+ std::string err = image.GetError();
+ printf("Error saving PNG '%s': %s\n", err.c_str());
+ return 2;
+ }
+
+ return 0;
+}