diff options
| -rw-r--r-- | test/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | test/io/errortest_eof1 | bin | 0 -> 43 bytes | |||
| -rw-r--r-- | test/io/read_test.cpp | 13 |
3 files changed, 15 insertions, 2 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 09520c31bd..63e6f20ed7 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -13,6 +13,6 @@ add_test(endian_str_test endian_str_test) add_executable(read_test io/read_test.cpp) target_link_libraries(read_test nbt++) add_custom_command(TARGET read_test POST_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/io/bigtest_uncompr ${CMAKE_CURRENT_BINARY_DIR}) + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/io/bigtest_uncompr ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/io/errortest_eof1 ${CMAKE_CURRENT_BINARY_DIR}) add_test(read_test read_test) diff --git a/test/io/errortest_eof1 b/test/io/errortest_eof1 Binary files differnew file mode 100644 index 0000000000..abb7ac564f --- /dev/null +++ b/test/io/errortest_eof1 diff --git a/test/io/read_test.cpp b/test/io/read_test.cpp index 0b29483f1e..d13402c2ea 100644 --- a/test/io/read_test.cpp +++ b/test/io/read_test.cpp @@ -143,9 +143,22 @@ void test_read_bigtest() {0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f})); } +void test_read_errors() +{ + std::ifstream file; + nbt::io::stream_reader reader(file); + + //EOF within a tag_double payload + file.open("errortest_eof1", std::ios::binary); + ASSERT(file); + EXPECT_EXCEPTION(reader.read_tag(), io::input_error); + ASSERT(!file); +} + int main() { test_stream_reader_big(); test_stream_reader_little(); test_read_bigtest(); + test_read_errors(); } |
