merge small unit tests to make running the tests quicker. expand the test framework a bit. add ax_boost_random.m4 script to link against boost.random correctly from makefile.
This commit is contained in:
@@ -58,10 +58,10 @@ entry decode(std::string const& str)
|
||||
return bdecode(str.begin(), str.end());
|
||||
}
|
||||
|
||||
int test_main()
|
||||
TORRENT_TEST(bencoding)
|
||||
{
|
||||
// ** strings **
|
||||
{
|
||||
{
|
||||
entry e("spam");
|
||||
TEST_CHECK(encode(e) == "4:spam");
|
||||
TEST_CHECK(decode(encode(e)) == e);
|
||||
@@ -119,7 +119,7 @@ int test_main()
|
||||
TEST_CHECK(e.type() == lazy_entry::int_t);
|
||||
TEST_CHECK(e.int_value() == 12453);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
char b[] = "26:abcdefghijklmnopqrstuvwxyz";
|
||||
lazy_entry e;
|
||||
@@ -256,25 +256,25 @@ int test_main()
|
||||
// test invalid encoding
|
||||
{
|
||||
unsigned char buf[] =
|
||||
{ 0x64 , 0x31 , 0x3a , 0x61 , 0x64 , 0x32 , 0x3a , 0x69
|
||||
, 0x64 , 0x32 , 0x30 , 0x3a , 0x2a , 0x21 , 0x19 , 0x89
|
||||
, 0x9f , 0xcd , 0x5f , 0xc9 , 0xbc , 0x80 , 0xc1 , 0x76
|
||||
, 0xfe , 0xe0 , 0xc6 , 0x84 , 0x2d , 0xf6 , 0xfc , 0xb8
|
||||
, 0x39 , 0x3a , 0x69 , 0x6e , 0x66 , 0x6f , 0x5f , 0x68
|
||||
, 0x61 , 0xae , 0x68 , 0x32 , 0x30 , 0x3a , 0x14 , 0x78
|
||||
, 0xd5 , 0xb0 , 0xdc , 0xf6 , 0x82 , 0x42 , 0x32 , 0xa0
|
||||
, 0xd6 , 0x88 , 0xeb , 0x48 , 0x57 , 0x01 , 0x89 , 0x40
|
||||
, 0x4e , 0xbc , 0x65 , 0x31 , 0x3a , 0x71 , 0x39 , 0x3a
|
||||
, 0x67 , 0x65 , 0x74 , 0x5f , 0x70 , 0x65 , 0x65 , 0x72
|
||||
, 0x78 , 0xff , 0x3a , 0x74 , 0x38 , 0x3a , 0xaa , 0xd4
|
||||
, 0xa1 , 0x88 , 0x7a , 0x8d , 0xc3 , 0xd6 , 0x31 , 0x3a
|
||||
, 0x79 , 0x31 , 0xae , 0x71 , 0x65 , 0};
|
||||
{ 0x64, 0x31, 0x3a, 0x61, 0x64, 0x32, 0x3a, 0x69
|
||||
, 0x64, 0x32, 0x30, 0x3a, 0x2a, 0x21, 0x19, 0x89
|
||||
, 0x9f, 0xcd, 0x5f, 0xc9, 0xbc, 0x80, 0xc1, 0x76
|
||||
, 0xfe, 0xe0, 0xc6, 0x84, 0x2d, 0xf6, 0xfc, 0xb8
|
||||
, 0x39, 0x3a, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x68
|
||||
, 0x61, 0xae, 0x68, 0x32, 0x30, 0x3a, 0x14, 0x78
|
||||
, 0xd5, 0xb0, 0xdc, 0xf6, 0x82, 0x42, 0x32, 0xa0
|
||||
, 0xd6, 0x88, 0xeb, 0x48, 0x57, 0x01, 0x89, 0x40
|
||||
, 0x4e, 0xbc, 0x65, 0x31, 0x3a, 0x71, 0x39, 0x3a
|
||||
, 0x67, 0x65, 0x74, 0x5f, 0x70, 0x65, 0x65, 0x72
|
||||
, 0x78, 0xff, 0x3a, 0x74, 0x38, 0x3a, 0xaa, 0xd4
|
||||
, 0xa1, 0x88, 0x7a, 0x8d, 0xc3, 0xd6, 0x31, 0x3a
|
||||
, 0x79, 0x31, 0xae, 0x71, 0x65, 0};
|
||||
|
||||
printf("%s\n", buf);
|
||||
lazy_entry e;
|
||||
error_code ec;
|
||||
int ret = lazy_bdecode((char*)buf, (char*)buf + sizeof(buf), e, ec);
|
||||
TEST_CHECK(ret == -1);
|
||||
TEST_CHECK(ret == -1);
|
||||
}
|
||||
|
||||
// test the depth limit
|
||||
@@ -496,7 +496,7 @@ int test_main()
|
||||
}
|
||||
|
||||
{
|
||||
unsigned char buf[] = { 0x44 , 0x91 , 0x3a };
|
||||
unsigned char buf[] = { 0x44, 0x91, 0x3a };
|
||||
entry ent = bdecode(buf, buf + sizeof(buf));
|
||||
TEST_CHECK(ent == entry());
|
||||
}
|
||||
|
Reference in New Issue
Block a user