mirror of
https://github.com/rakshasa/rtorrent.git
synced 2026-08-12 21:22:31 +00:00
* Added 'rpc/fixed_key.h' header.
* Replaced Command with command_base. git-svn-id: svn://rakshasa.no/libtorrent/trunk/rtorrent@1168 e378c898-3ddf-0310-93e7-cc216c733640
This commit is contained in:
+22
-22
@@ -6,33 +6,33 @@ CPPUNIT_TEST_SUITE_REGISTRATION(CommandTest);
|
||||
|
||||
bool
|
||||
command_stack_all_empty() {
|
||||
return std::find_if(rpc::Command::stack_begin(), rpc::Command::stack_end(),
|
||||
std::mem_fun_ref(&torrent::Object::is_not_empty)) == rpc::Command::stack_end();
|
||||
return std::find_if(rpc::command_base::stack_begin(), rpc::command_base::stack_end(),
|
||||
std::mem_fun_ref(&torrent::Object::is_not_empty)) == rpc::command_base::stack_end();
|
||||
}
|
||||
|
||||
void
|
||||
CommandTest::test_stack() {
|
||||
torrent::Object::list_type args;
|
||||
rpc::Command::stack_type stack;
|
||||
rpc::command_base::stack_type stack;
|
||||
torrent::Object* last_stack;
|
||||
|
||||
// Test empty stack.
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
|
||||
last_stack = rpc::Command::push_stack(args, &stack);
|
||||
last_stack = rpc::command_base::push_stack(args, &stack);
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
|
||||
rpc::Command::pop_stack(&stack, last_stack);
|
||||
rpc::command_base::pop_stack(&stack, last_stack);
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
|
||||
// Test stack with one.
|
||||
args.push_back(int64_t(1));
|
||||
|
||||
last_stack = rpc::Command::push_stack(args, &stack);
|
||||
last_stack = rpc::command_base::push_stack(args, &stack);
|
||||
CPPUNIT_ASSERT(!command_stack_all_empty());
|
||||
CPPUNIT_ASSERT(rpc::Command::stack_begin()->as_value() == 1);
|
||||
CPPUNIT_ASSERT(rpc::command_base::stack_begin()->as_value() == 1);
|
||||
|
||||
rpc::Command::pop_stack(&stack, last_stack);
|
||||
rpc::command_base::pop_stack(&stack, last_stack);
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
|
||||
// Test stack with two
|
||||
@@ -40,44 +40,44 @@ CommandTest::test_stack() {
|
||||
args.push_back(int64_t(2));
|
||||
args.push_back(int64_t(3));
|
||||
|
||||
last_stack = rpc::Command::push_stack(args, &stack);
|
||||
last_stack = rpc::command_base::push_stack(args, &stack);
|
||||
CPPUNIT_ASSERT(!command_stack_all_empty());
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[0].as_value() == 2);
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[1].as_value() == 3);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[0].as_value() == 2);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[1].as_value() == 3);
|
||||
|
||||
rpc::Command::pop_stack(&stack, last_stack);
|
||||
rpc::command_base::pop_stack(&stack, last_stack);
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
}
|
||||
|
||||
void
|
||||
CommandTest::test_stack_double() {
|
||||
torrent::Object::list_type args;
|
||||
rpc::Command::stack_type stack_first;
|
||||
rpc::Command::stack_type stack_second;
|
||||
rpc::command_base::stack_type stack_first;
|
||||
rpc::command_base::stack_type stack_second;
|
||||
torrent::Object* last_stack_first;
|
||||
torrent::Object* last_stack_second;
|
||||
|
||||
// Test double-stacked.
|
||||
args.push_back(int64_t(1));
|
||||
|
||||
last_stack_first = rpc::Command::push_stack(args, &stack_first);
|
||||
last_stack_first = rpc::command_base::push_stack(args, &stack_first);
|
||||
CPPUNIT_ASSERT(!command_stack_all_empty());
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[0].as_value() == 1);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[0].as_value() == 1);
|
||||
|
||||
args.clear();
|
||||
args.push_back(int64_t(2));
|
||||
args.push_back(int64_t(3));
|
||||
|
||||
last_stack_second = rpc::Command::push_stack(args, &stack_second);
|
||||
last_stack_second = rpc::command_base::push_stack(args, &stack_second);
|
||||
CPPUNIT_ASSERT(!command_stack_all_empty());
|
||||
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[0].as_value() == 2);
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[1].as_value() == 3);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[0].as_value() == 2);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[1].as_value() == 3);
|
||||
|
||||
rpc::Command::pop_stack(&stack_second, last_stack_second);
|
||||
rpc::command_base::pop_stack(&stack_second, last_stack_second);
|
||||
CPPUNIT_ASSERT(!command_stack_all_empty());
|
||||
CPPUNIT_ASSERT(rpc::Command::current_stack[0].as_value() == 1);
|
||||
CPPUNIT_ASSERT(rpc::command_base::current_stack[0].as_value() == 1);
|
||||
|
||||
rpc::Command::pop_stack(&stack_first, last_stack_first);
|
||||
rpc::command_base::pop_stack(&stack_first, last_stack_first);
|
||||
CPPUNIT_ASSERT(command_stack_all_empty());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user