improvements to lazy_bdecode
This commit is contained in:
@@ -77,6 +77,9 @@ int test_main()
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e);
|
||||
TORRENT_ASSERT(ret == 0);
|
||||
std::cout << e << std::endl;
|
||||
std::pair<const char*, int> section = e.data_section();
|
||||
TORRENT_ASSERT(memcmp(b, section.first, section.second) == 0);
|
||||
TORRENT_ASSERT(section.second == sizeof(b) - 1);
|
||||
TORRENT_ASSERT(e.type() == lazy_entry::int_t);
|
||||
TORRENT_ASSERT(e.int_value() == 12453);
|
||||
}
|
||||
@@ -87,6 +90,9 @@ int test_main()
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e);
|
||||
TORRENT_ASSERT(ret == 0);
|
||||
std::cout << e << std::endl;
|
||||
std::pair<const char*, int> section = e.data_section();
|
||||
TORRENT_ASSERT(memcmp(b, section.first, section.second) == 0);
|
||||
TORRENT_ASSERT(section.second == sizeof(b) - 1);
|
||||
TORRENT_ASSERT(e.type() == lazy_entry::string_t);
|
||||
TORRENT_ASSERT(e.string_value() == std::string("abcdefghijklmnopqrstuvwxyz"));
|
||||
TORRENT_ASSERT(e.string_length() == 26);
|
||||
@@ -98,6 +104,9 @@ int test_main()
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e);
|
||||
TORRENT_ASSERT(ret == 0);
|
||||
std::cout << e << std::endl;
|
||||
std::pair<const char*, int> section = e.data_section();
|
||||
TORRENT_ASSERT(memcmp(b, section.first, section.second) == 0);
|
||||
TORRENT_ASSERT(section.second == sizeof(b) - 1);
|
||||
TORRENT_ASSERT(e.type() == lazy_entry::list_t);
|
||||
TORRENT_ASSERT(e.list_size() == 2);
|
||||
TORRENT_ASSERT(e.list_at(0)->type() == lazy_entry::int_t);
|
||||
@@ -105,6 +114,9 @@ int test_main()
|
||||
TORRENT_ASSERT(e.list_at(0)->int_value() == 12453);
|
||||
TORRENT_ASSERT(e.list_at(1)->string_value() == std::string("aaa"));
|
||||
TORRENT_ASSERT(e.list_at(1)->string_length() == 3);
|
||||
section = e.list_at(1)->data_section();
|
||||
TORRENT_ASSERT(memcmp("3:aaa", section.first, section.second) == 0);
|
||||
TORRENT_ASSERT(section.second == 5);
|
||||
}
|
||||
|
||||
{
|
||||
@@ -113,6 +125,9 @@ int test_main()
|
||||
int ret = lazy_bdecode(b, b + sizeof(b)-1, e);
|
||||
TORRENT_ASSERT(ret == 0);
|
||||
std::cout << e << std::endl;
|
||||
std::pair<const char*, int> section = e.data_section();
|
||||
TORRENT_ASSERT(memcmp(b, section.first, section.second) == 0);
|
||||
TORRENT_ASSERT(section.second == sizeof(b) - 1);
|
||||
TORRENT_ASSERT(e.type() == lazy_entry::dict_t);
|
||||
TORRENT_ASSERT(e.dict_size() == 3);
|
||||
TORRENT_ASSERT(e.dict_find("a")->type() == lazy_entry::int_t);
|
||||
|
Reference in New Issue
Block a user