From 0b94624aa9ab1454d4c89ec8b9ca6e87497c1552 Mon Sep 17 00:00:00 2001 From: Yury Melnichek Date: Tue, 25 Sep 2012 20:38:21 +0200 Subject: [PATCH] Add a unit test for incorrect DDVector size. --- coding/coding_tests/dd_vector_test.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/coding/coding_tests/dd_vector_test.cpp b/coding/coding_tests/dd_vector_test.cpp index a166d6bd14..9eadfb87b2 100644 --- a/coding/coding_tests/dd_vector_test.cpp +++ b/coding/coding_tests/dd_vector_test.cpp @@ -22,3 +22,22 @@ UNIT_TEST(DDVector) for (size_t i = 0; i < v.size(); ++i, ++it) TEST_EQUAL(v[i], *it, ()); } + +UNIT_TEST(DDVector_IncorrectSize) +{ + typedef DDVector Vector; + char const data[] = "ab"; + MemReader reader(data, ARRAY_SIZE(data)); + + bool exceptionCaught = false; + try + { + Vector v(reader); + } + catch (Vector::OpenException & e) + { + exceptionCaught = true; + } + + TEST(exceptionCaught, ()); +}