mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-09-26 20:17:25 +00:00
Fill in missing tests and documentation.
This commit is contained in:
@@ -422,7 +422,9 @@ Asserts that the pointers point to the same memory location.
|
||||
|
||||
#### `TEST_ASSERT_NOT_EQUAL_PTR (expected, actual)`
|
||||
|
||||
Asserts that the pointers DO NOT point to the same memory location.
|
||||
Asserts that the pointers DO NOT point to the same memory location. Two NULL
|
||||
pointers are considered equal and will cause this assertion to fail. A NULL
|
||||
pointer and a non-NULL pointer are considered not equal and will pass.
|
||||
|
||||
#### `TEST_ASSERT_EQUAL_STRING (expected, actual)`
|
||||
|
||||
@@ -433,7 +435,10 @@ equivalent.
|
||||
|
||||
#### `TEST_ASSERT_NOT_EQUAL_STRING (expected, actual)`
|
||||
|
||||
Asserts that the null terminated (`’\0’`) strings are NOT identical.
|
||||
Asserts that the null terminated (`’\0’`) strings are NOT identical. The
|
||||
assertion passes if the strings differ in length or content at any point before
|
||||
their null terminators. A NULL pointer and a non-NULL string are considered not
|
||||
equal and will pass. Two NULL pointers are considered equal and will fail.
|
||||
|
||||
#### `TEST_ASSERT_EQUAL_STRING_LEN (expected, actual, len)`
|
||||
|
||||
@@ -442,7 +447,11 @@ It checks only the first `len` characters, not the entire string.
|
||||
|
||||
#### `TEST_ASSERT_NOT_EQUAL_STRING_LEN (expected, actual, len)`
|
||||
|
||||
Asserts that the null terminated (`’\0’`) strings are NOT identical up to the specified length.
|
||||
Asserts that the null terminated (`’\0’`) strings are NOT identical within the
|
||||
first `len` characters. The assertion passes if the strings differ at any
|
||||
position within the specified length. A NULL pointer and a non-NULL string are
|
||||
considered not equal and will pass. Two NULL pointers are considered equal and
|
||||
will fail. Specifying a `len` of zero is considered pointless and will fail.
|
||||
|
||||
#### `TEST_ASSERT_EQUAL_MEMORY (expected, actual, len)`
|
||||
|
||||
@@ -453,7 +462,11 @@ the `len` parameter.
|
||||
#### `TEST_ASSERT_NOT_EQUAL_MEMORY (expected, actual, len)`
|
||||
|
||||
Asserts that the contents of the memory specified by the `expected` and `actual`
|
||||
pointers is NOT identical.
|
||||
pointers is NOT identical within the first `len` bytes. The assertion passes if
|
||||
any byte differs within that range. A NULL pointer and a non-NULL pointer are
|
||||
considered not equal and will pass. Two NULL pointers (or the same pointer) are
|
||||
considered equal and will fail. Specifying a `len` of zero is considered
|
||||
pointless and will fail.
|
||||
|
||||
### Arrays
|
||||
|
||||
|
||||
@@ -700,6 +700,40 @@ void testNotEqualPointers(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualPtr(void)
|
||||
{
|
||||
int v0, v1;
|
||||
int *p0, *p1;
|
||||
|
||||
v0 = 19467;
|
||||
v1 = 18271;
|
||||
p0 = &v0;
|
||||
p1 = &v1;
|
||||
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(p0, p1);
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(&v0, &v1);
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(p0, &v1);
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(NULL, &v0);
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(&v0, NULL);
|
||||
}
|
||||
|
||||
void testNotNotEqualPointers(void)
|
||||
{
|
||||
int v0;
|
||||
int *p0 = &v0;
|
||||
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(p0, p0);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualPointers_BothNull(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_PTR(NULL, NULL);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testIntsWithinDelta(void)
|
||||
{
|
||||
TEST_ASSERT_INT_WITHIN(1, 5000, 5001);
|
||||
|
||||
@@ -80,3 +80,32 @@ void testNotEqualMemoryLengthZero(void)
|
||||
TEST_ASSERT_EQUAL_MEMORY(NULL, NULL, 0);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualMemory(void)
|
||||
{
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY("foo", "bar", 3);
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY_MESSAGE("fool", "food", 4, "fool should not equal food");
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY(NULL, "food", 4);
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY("fool", NULL, 4);
|
||||
}
|
||||
|
||||
void testNotNotEqualMemory1(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY("foo", "foo", 3);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualMemory2(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY(NULL, NULL, 1);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualMemoryLengthZero(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_MEMORY("foo", "bar", 0);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
@@ -173,6 +173,70 @@ void testNotEqualString_ActualStringIsLonger(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStrings(void)
|
||||
{
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo", "bar");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_MESSAGE("foo", "bar", "foo should not equal bar");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo", "");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("", "bar");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo", "foo2");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo2", "foo");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING(NULL, "bar");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo", NULL);
|
||||
}
|
||||
|
||||
void testNotNotEqualString1(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING("foo", "foo");
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualString2(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING(NULL, NULL);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStringsLen(void)
|
||||
{
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foobar", "foobaz", 6);
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN_MESSAGE("foo", "bar", 3, "foo should not equal bar");
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foo", "", 3);
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("", "bar", 3);
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN(NULL, "bar", 3);
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foo", NULL, 3);
|
||||
}
|
||||
|
||||
void testNotNotEqualStringLen1(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foobar", "foobaz", 5);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualStringLen2(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foo", "foo", 3);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualStringLen3(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN(NULL, NULL, 3);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotNotEqualStringLenZero(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_NOT_EQUAL_STRING_LEN("foo", "bar", 0);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testEqualStringArrays(void)
|
||||
{
|
||||
const char *testStrings[] = { "foo", "boo", "woo", "moo" };
|
||||
|
||||
Reference in New Issue
Block a user