Fixed test asserts

master
Tycho 2014-03-10 13:12:43 -07:00
parent bb28f0d1e3
commit e9e2852ce1
4 changed files with 37 additions and 37 deletions

View File

@ -46,9 +46,6 @@
#ifdef SELF_TEST
#define assert_test(x) ( !!(x) || \
LOGERROR("Assertion failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), abort(1))
/// Self-test of the VarInt-reading and writing code
static class cByteBufferSelfTest
{

View File

@ -32,15 +32,15 @@ public:
cCompositeChat Msg;
Msg.ParseText("Testing @2color codes and http://links parser");
const cCompositeChat::cParts & Parts = Msg.GetParts();
assert(Parts.size() == 4);
assert(Parts[0]->m_PartType == cCompositeChat::ptText);
assert(Parts[1]->m_PartType == cCompositeChat::ptText);
assert(Parts[2]->m_PartType == cCompositeChat::ptUrl);
assert(Parts[3]->m_PartType == cCompositeChat::ptText);
assert(Parts[0]->m_Style == "");
assert(Parts[1]->m_Style == "@2");
assert(Parts[2]->m_Style == "@2");
assert(Parts[3]->m_Style == "@2");
assert_test(Parts.size() == 4);
assert_test(Parts[0]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[1]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[2]->m_PartType == cCompositeChat::ptUrl);
assert_test(Parts[3]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[0]->m_Style == "");
assert_test(Parts[1]->m_Style == "@2");
assert_test(Parts[2]->m_Style == "@2");
assert_test(Parts[3]->m_Style == "@2");
}
void TestParser2(void)
@ -48,15 +48,15 @@ public:
cCompositeChat Msg;
Msg.ParseText("@3Advanced stuff: @5overriding color codes and http://links.with/@4color-in-them handling");
const cCompositeChat::cParts & Parts = Msg.GetParts();
assert(Parts.size() == 4);
assert(Parts[0]->m_PartType == cCompositeChat::ptText);
assert(Parts[1]->m_PartType == cCompositeChat::ptText);
assert(Parts[2]->m_PartType == cCompositeChat::ptUrl);
assert(Parts[3]->m_PartType == cCompositeChat::ptText);
assert(Parts[0]->m_Style == "@3");
assert(Parts[1]->m_Style == "@5");
assert(Parts[2]->m_Style == "@5");
assert(Parts[3]->m_Style == "@5");
assert_test(Parts.size() == 4);
assert_test(Parts[0]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[1]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[2]->m_PartType == cCompositeChat::ptUrl);
assert_test(Parts[3]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[0]->m_Style == "@3");
assert_test(Parts[1]->m_Style == "@5");
assert_test(Parts[2]->m_Style == "@5");
assert_test(Parts[3]->m_Style == "@5");
}
void TestParser3(void)
@ -64,11 +64,11 @@ public:
cCompositeChat Msg;
Msg.ParseText("http://links.starting the text");
const cCompositeChat::cParts & Parts = Msg.GetParts();
assert(Parts.size() == 2);
assert(Parts[0]->m_PartType == cCompositeChat::ptUrl);
assert(Parts[1]->m_PartType == cCompositeChat::ptText);
assert(Parts[0]->m_Style == "");
assert(Parts[1]->m_Style == "");
assert_test(Parts.size() == 2);
assert_test(Parts[0]->m_PartType == cCompositeChat::ptUrl);
assert_test(Parts[1]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[0]->m_Style == "");
assert_test(Parts[1]->m_Style == "");
}
void TestParser4(void)
@ -76,11 +76,11 @@ public:
cCompositeChat Msg;
Msg.ParseText("links finishing the text: http://some.server");
const cCompositeChat::cParts & Parts = Msg.GetParts();
assert(Parts.size() == 2);
assert(Parts[0]->m_PartType == cCompositeChat::ptText);
assert(Parts[1]->m_PartType == cCompositeChat::ptUrl);
assert(Parts[0]->m_Style == "");
assert(Parts[1]->m_Style == "");
assert_test(Parts.size() == 2);
assert_test(Parts[0]->m_PartType == cCompositeChat::ptText);
assert_test(Parts[1]->m_PartType == cCompositeChat::ptUrl);
assert_test(Parts[0]->m_Style == "");
assert_test(Parts[1]->m_Style == "");
}
void TestParser5(void)
@ -88,9 +88,9 @@ public:
cCompositeChat Msg;
Msg.ParseText("http://only.links");
const cCompositeChat::cParts & Parts = Msg.GetParts();
assert(Parts.size() == 1);
assert(Parts[0]->m_PartType == cCompositeChat::ptUrl);
assert(Parts[0]->m_Style == "");
assert_test(Parts.size() == 1);
assert_test(Parts[0]->m_PartType == cCompositeChat::ptUrl);
assert_test(Parts[0]->m_Style == "");
}
} gTest;

View File

@ -192,7 +192,9 @@ void cCraftingGrid::Dump(void)
{
for (int y = 0; y < m_Height; y++) for (int x = 0; x < m_Width; x++)
{
#ifdef _DEBUG
int idx = x + m_Width * y;
#endif
LOGD("Slot (%d, %d): Type %d, health %d, count %d",
x, y, m_Items[idx].m_ItemType, m_Items[idx].m_ItemDamage, m_Items[idx].m_ItemCount
);

View File

@ -234,9 +234,10 @@ template class SizeChecker<UInt16, 2>;
// Pretty much the same as ASSERT() but stays in Release builds
#define VERIFY( x ) ( !!(x) || ( LOGERROR("Verification failed: %s, file %s, line %i", #x, __FILE__, __LINE__ ), exit(1), 0 ) )
// Same as assert but in all Self test builds
#ifdef SELF_TEST
#define assert_test(x) ( !!(x) || (assert(0), exit(1), 0))
#endif
/// A generic interface used mainly in ForEach() functions
template <typename Type> class cItemCallback