From e9dd438bd78b10c56e47479db7c7b3e2a3e9ab3a Mon Sep 17 00:00:00 2001 From: ljfa-ag Date: Thu, 6 Aug 2015 13:33:23 +0200 Subject: Add test for read failure (EOF in tag) --- test/io/read_test.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/io/read_test.cpp') 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(); } -- cgit 0.0.5-2-1-g0f52