more unit testing of diff xmit
This commit is contained in:
@@ -415,13 +415,21 @@ bool AnimQueue::valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string AnimQueue::debug_string() const {
|
||||
std::string AnimQueue::steps_debug_string() const {
|
||||
std::ostringstream oss;
|
||||
for (int i = 0; i < int(size()); i++) {
|
||||
oss << nth(i).debug_string() << "; ";
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
std::string AnimQueue::full_debug_string() const {
|
||||
std::ostringstream oss;
|
||||
for (int i = 0; i < int(size()); i++) {
|
||||
oss << nth(i).debug_string() << "; ";
|
||||
}
|
||||
oss << "version=" << version_number();
|
||||
oss << "; limit=" << size_limit();
|
||||
for (int i = 0; i < int(size()); i++) {
|
||||
oss << "; " << nth(i).debug_string();
|
||||
}
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
@@ -553,7 +561,7 @@ LuaDefine(unittests_animqueue, "c") {
|
||||
|
||||
// Debug string of a newly initialized queue
|
||||
LuaAssert(L, aq.valid());
|
||||
LuaAssertStrEq(L, aq.debug_string(), "version=1; limit=10; id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=");
|
||||
LuaAssertStrEq(L, aq.full_debug_string(), "id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=; version=1; limit=10");
|
||||
|
||||
// Test the step setters.
|
||||
stp.clear();
|
||||
@@ -578,16 +586,16 @@ LuaDefine(unittests_animqueue, "c") {
|
||||
// Test that we can clear a queue.
|
||||
aq.full_clear_and_set_limit(3);
|
||||
LuaAssert(L, aq.valid());
|
||||
LuaAssertStrEq(L, aq.debug_string(), "version=1; limit=3; id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=");
|
||||
LuaAssertStrEq(L, aq.full_debug_string(), "id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=; version=1; limit=3");
|
||||
|
||||
// Add a step to a queue.
|
||||
aq.full_clear_and_set_limit(3);
|
||||
LuaAssert(L, stp.from_string("action=walk"));
|
||||
aq.add(12345, stp);
|
||||
LuaAssertStrEq(L, aq.debug_string(),
|
||||
"version=2; limit=3; "
|
||||
LuaAssertStrEq(L, aq.full_debug_string(),
|
||||
"id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=; "
|
||||
"id=12345 action=walk");
|
||||
"id=12345 action=walk; "
|
||||
"version=2; limit=3");
|
||||
|
||||
// Exceed the length limit, dropping first element.
|
||||
aq.full_clear_and_set_limit(3);
|
||||
@@ -595,11 +603,11 @@ LuaDefine(unittests_animqueue, "c") {
|
||||
aq.add(12345, stp);
|
||||
aq.add(12346, stp);
|
||||
aq.add(12347, stp);
|
||||
LuaAssertStrEq(L, aq.debug_string(),
|
||||
"version=4; limit=3; "
|
||||
LuaAssertStrEq(L, aq.full_debug_string(),
|
||||
"id=0 action= plane=foo x=0 y=0 z=0 facing=0 graphic=; "
|
||||
"id=12346 action=walk plane=foo; "
|
||||
"id=12347 action=walk plane=foo"
|
||||
"id=12347 action=walk plane=foo; "
|
||||
"version=4; limit=3"
|
||||
);
|
||||
|
||||
// Test serialization and deserialization.
|
||||
@@ -614,12 +622,12 @@ LuaDefine(unittests_animqueue, "c") {
|
||||
aq.serialize(&sb);
|
||||
aqds.deserialize(&sb);
|
||||
|
||||
LuaAssertStrEq(L, aqds.debug_string(),
|
||||
"version=0; limit=5; "
|
||||
LuaAssertStrEq(L, aqds.full_debug_string(),
|
||||
"id=0 action= plane= x=0 y=0 z=0 facing=0 graphic=; "
|
||||
"id=12345 action=walk x=3 y=4 z=5; "
|
||||
"id=12346 action=setgraphic graphic=banana; "
|
||||
"id=12347 action=setfacing facing=301"
|
||||
"id=12347 action=setfacing facing=301; "
|
||||
"version=0; limit=5"
|
||||
);
|
||||
|
||||
// Test difference transmission
|
||||
|
||||
Reference in New Issue
Block a user