summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-09-23 00:33:33 +0200
committerPetr Mrázek <peterix@gmail.com>2015-09-23 00:44:46 +0200
commit076647597f2ebb6f243f34aacaacf0a974752085 (patch)
tree9c9be6623486aebdfeb9ab68a678adc3d88492b9 /test
parent7f38044924fe5f13a61c3265a73d0045ddd2a1b2 (diff)
downloadProject-Tick-076647597f2ebb6f243f34aacaacf0a974752085.tar.gz
Project-Tick-076647597f2ebb6f243f34aacaacf0a974752085.zip
Make zlib optional, adapt for including
Diffstat (limited to 'test')
-rw-r--r--test/CMakeLists.txt16
-rw-r--r--test/read_test.h5
-rw-r--r--test/write_test.h4
3 files changed, 19 insertions, 6 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 04a461a07a..5dedfcf1fb 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -11,6 +11,10 @@ function(use_testfiles target)
copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/testfiles ${CMAKE_CURRENT_BINARY_DIR})
endfunction()
+if(NBT_USE_ZLIB)
+ set(EXTRA_TEST_LIBS ${ZLIB_LIBRARY})
+endif()
+
CXXTEST_ADD_TEST(nbttest nbttest.cpp ${CMAKE_CURRENT_SOURCE_DIR}/nbttest.h)
target_link_libraries(nbttest nbt++)
@@ -18,16 +22,18 @@ CXXTEST_ADD_TEST(endian_str_test endian_str_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}
target_link_libraries(endian_str_test nbt++)
CXXTEST_ADD_TEST(read_test read_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/read_test.h)
-target_link_libraries(read_test nbt++ z)
+target_link_libraries(read_test nbt++ ${EXTRA_TEST_LIBS})
use_testfiles(read_test)
CXXTEST_ADD_TEST(write_test write_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/write_test.h)
-target_link_libraries(write_test nbt++ z)
+target_link_libraries(write_test nbt++ ${EXTRA_TEST_LIBS})
use_testfiles(write_test)
-CXXTEST_ADD_TEST(zlibstream_test zlibstream_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zlibstream_test.h)
-target_link_libraries(zlibstream_test nbt++ z)
-use_testfiles(zlibstream_test)
+if(NBT_USE_ZLIB)
+ CXXTEST_ADD_TEST(zlibstream_test zlibstream_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/zlibstream_test.h)
+ target_link_libraries(zlibstream_test nbt++ ${EXTRA_TEST_LIBS})
+ use_testfiles(zlibstream_test)
+endif()
add_executable(format_test format_test.cpp)
target_link_libraries(format_test nbt++)
diff --git a/test/read_test.h b/test/read_test.h
index eab30cfaad..e7c00a8d8e 100644
--- a/test/read_test.h
+++ b/test/read_test.h
@@ -19,7 +19,9 @@
*/
#include <cxxtest/TestSuite.h>
#include "io/stream_reader.h"
+#ifdef NBT_HAVE_ZLIB
#include "io/izlibstream.h"
+#endif
#include "nbt_tags.h"
#include <iostream>
#include <fstream>
@@ -214,9 +216,9 @@ public:
"Even though unprovided for by NBT, the library should also handle "
"the case where the file consists of something else than tag_compound"));
}
-
void test_read_gzip()
{
+#ifdef NBT_HAVE_ZLIB
std::ifstream file("bigtest.nbt", std::ios::binary);
zlib::izlibstream igzs(file);
TS_ASSERT(file && igzs);
@@ -225,5 +227,6 @@ public:
TS_ASSERT(igzs);
TS_ASSERT_EQUALS(pair.first, "Level");
verify_bigtest_structure(*pair.second);
+#endif
}
};
diff --git a/test/write_test.h b/test/write_test.h
index 69c5dfdb97..a302891074 100644
--- a/test/write_test.h
+++ b/test/write_test.h
@@ -20,8 +20,10 @@
#include <cxxtest/TestSuite.h>
#include "io/stream_writer.h"
#include "io/stream_reader.h"
+#ifdef NBT_HAVE_ZLIB
#include "io/ozlibstream.h"
#include "io/izlibstream.h"
+#endif
#include "nbt_tags.h"
#include <iostream>
#include <fstream>
@@ -247,6 +249,7 @@ public:
TS_ASSERT_EQUALS(orig_pair.first, written_pair.first);
TS_ASSERT(*orig_pair.second == *written_pair.second);
+#ifdef NBT_HAVE_ZLIB
//Now with gzip compression
sstr.str("");
zlib::ozlibstream ogzs(sstr, -1, true);
@@ -260,5 +263,6 @@ public:
TS_ASSERT(igzs);
TS_ASSERT_EQUALS(orig_pair.first, written_pair.first);
TS_ASSERT(*orig_pair.second == *written_pair.second);
+#endif
}
};