- centralized pretty printing so people can use it more easily

- updated unity helper examples to get them working again
- got examples running again

git-svn-id: http://unity.svn.sourceforge.net/svnroot/unity/trunk@65 e7d17a6e-8845-0410-bbbc-c8efb4fdad7e
This commit is contained in:
mvandervoord
2010-03-21 02:53:17 +00:00
parent 07d2848dd4
commit b10a094214
11 changed files with 72 additions and 136 deletions

@ -5,41 +5,19 @@
static char message[1024];
void AssertEqualUintArray(const unsigned int* expected, const unsigned int* actual, const unsigned int length)
{
unsigned int i;
for (i = 0; i < length; i++)
{
sprintf(message, "Array comparison failed at index %u.", i);
TEST_ASSERT_EQUAL_UINT_MESSAGE(expected[i], actual[i], message);
}
}
void AssertEqualIntArray(const int* expected, const int* actual, const unsigned int length)
{
unsigned int i;
for (i = 0; i < length; i++)
{
sprintf(message, "Array comparison failed at index %u.", i);
TEST_ASSERT_EQUAL_INT_MESSAGE(expected[i], actual[i], message);
}
}
void AssertFloatArrayWithin(const float tolerance, const float* expected, const float* actual, const unsigned int length)
void AssertFloatArrayWithin(const float tolerance, const float* expected, const float* actual, const unsigned int length, const unsigned short line)
{
unsigned int i;
for (i = 0; i < length; i++)
{
sprintf(message, "Array mismatch at index %u, Expected %f, Actual %f, Tolerance %f, Delta %f", i, expected[i], actual[i], tolerance, (expected[i]-actual[i]));
TEST_ASSERT_FLOAT_WITHIN_MESSAGE(tolerance, expected[i], actual[i], message);
UNITY_TEST_ASSERT_WITHIN_FLOAT(tolerance, expected[i], actual[i], line, message);
}
}
void AssertEqualExampleStruct(EXAMPLE_STRUCT_T expected, EXAMPLE_STRUCT_T actual)
void AssertEqualExampleStruct(const EXAMPLE_STRUCT_T expected, const EXAMPLE_STRUCT_T actual, const unsigned short line)
{
TEST_ASSERT_EQUAL_INT_MESSAGE(expected.x, actual.x, "Example Struct Failed For Field x");
TEST_ASSERT_EQUAL_INT_MESSAGE(expected.y, actual.y, "Example Struct Failed For Field y");
UNITY_TEST_ASSERT_EQUAL_INT(expected.x, actual.x, line, "Example Struct Failed For Field x");
UNITY_TEST_ASSERT_EQUAL_INT(expected.y, actual.y, line, "Example Struct Failed For Field y");
}