1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 00:15:58 +01:00

Add assertion for checking empty null-terminated arrays. This is particularly useful for check c strings.

This commit is contained in:
mvandervoord
2020-03-16 15:04:40 -04:00
parent 5e9acef74f
commit bad429428d
4 changed files with 42 additions and 0 deletions

View File

@@ -258,6 +258,33 @@ void testNotNullShouldFailIfNULL(void)
VERIFY_FAILS_END
}
void testIsEmpty(void)
{
const char* ptr1 = "\0";
const char* ptr2 = "hello";
TEST_ASSERT_EMPTY(ptr1);
TEST_ASSERT_NOT_EMPTY(ptr2);
}
void testIsEmptyShouldFailIfNot(void)
{
const char* ptr1 = "hello";
EXPECT_ABORT_BEGIN
TEST_ASSERT_EMPTY(ptr1);
VERIFY_FAILS_END
}
void testNotEmptyShouldFailIfEmpty(void)
{
const char* ptr1 = "\0";
EXPECT_ABORT_BEGIN
TEST_ASSERT_NOT_EMPTY(ptr1);
VERIFY_FAILS_END
}
void testIgnore(void)
{
EXPECT_ABORT_BEGIN