diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | test/microtest.h | 14 | ||||
| -rw-r--r-- | test/nbttest.cpp | 9 |
3 files changed, 29 insertions, 0 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..04672d2666 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,6 @@ +enable_testing() +include_directories(${libnbt++_SOURCE_DIR}/include) + +add_executable(nbttest nbttest.cpp) +target_link_libraries(nbttest nbt++) +add_test(nbttest nbttest) diff --git a/test/microtest.h b/test/microtest.h new file mode 100644 index 0000000000..8691ebb748 --- /dev/null +++ b/test/microtest.h @@ -0,0 +1,14 @@ +#ifndef MICROTEST_H +#define MICROTEST_H + +#include <type_traits> + +#define FAIL_TEST { std::cerr << "Assertion failed at " __FILE__ ":" << __LINE__ << std::endl; \ + exit(EXIT_FAILURE); } +#define ASSERT(expr) { if(!(expr)) FAIL_TEST } +#define EXPECT_EXCEPTION(expr, type) { \ + try { (expr); std::cerr << "Expected " #type " to be thrown" << std::endl; FAIL_TEST } \ + catch(type&) {} \ + catch(...) { std::cerr << "Expected " #type " to be thrown" << std::endl; FAIL_TEST } } + +#endif diff --git a/test/nbttest.cpp b/test/nbttest.cpp new file mode 100644 index 0000000000..eead43efd0 --- /dev/null +++ b/test/nbttest.cpp @@ -0,0 +1,9 @@ +#include "microtest.h" +#include "tag.h" +#include <cstdlib> +#include <iostream> + +int main() +{ + return EXIT_SUCCESS; +} |
