2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added tests the case where length < 0 is specified.
	* test/BencodeTest.cc
pull/1/head
Tatsuhiro Tsujikawa 2008-12-14 05:44:08 +00:00
parent 9b197e97d3
commit 057132cd5f
2 changed files with 18 additions and 1 deletions

View File

@ -1,3 +1,8 @@
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added tests the case where length < 0 is specified.
* test/BencodeTest.cc
2008-12-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed memory leak in decoderawstring()

View File

@ -244,7 +244,19 @@ void BencodeTest::testDecode()
bencode::decode("x:abc");
CPPUNIT_FAIL("exception must be thrown.");
} catch(RecoverableException& e) {
CPPUNIT_ASSERT_EQUAL(std::string("Integer expected but none found."),
CPPUNIT_ASSERT_EQUAL(std::string("A positive integer expected"
" but none found."),
std::string(e.what()));
}
}
{
// string with minus length
try {
bencode::decode("-1:a");
CPPUNIT_FAIL("exception must be thrown.");
} catch(RecoverableException& e) {
CPPUNIT_ASSERT_EQUAL(std::string("A positive integer expected"
" but none found."),
std::string(e.what()));
}
}