extend some unit tests. primarily test_alert_manager and fixed a bug in alert_manager

This commit is contained in:
Arvid Norberg
2015-04-11 18:44:43 +00:00
parent caf2b6ed07
commit baaeac7809
6 changed files with 150 additions and 18 deletions

View File

@@ -1162,7 +1162,29 @@ int test_main()
TEST_EQUAL(print_entry(e), "{ 'a': 1, 'b': 'foo', 'c': [ 1 ] }");
}
// TODO: test switch_underlying_buffer
// test switch_underlying_buffer
{
char b1[] = "d1:ai1e1:b3:foo1:cli1e-i2ee1:dd1:xi1eee";
char b2[] = "d1:ai1e1:b3:foo1:cli1e-i2ee1:dd1:xi1eee";
bdecode_node e;
error_code ec;
int pos;
int ret = bdecode(b1, b1 + sizeof(b1)-1, e, ec, &pos);
TEST_EQUAL(ret, -1);
TEST_EQUAL(pos, 22);
TEST_EQUAL(e.type(), bdecode_node::dict_t);
std::string string1 = print_entry(e);
printf("%s\n", string1.c_str());
e.switch_underlying_buffer(b2);
std::string string2 = print_entry(e);
printf("%s\n", string2.c_str());
TEST_EQUAL(string1, string2);
}
return 0;
}