mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-26 18:01:35 +01:00
Added support for TEST_ASSERT_EQUAL_STRING_LEN*
Compares two strings until maximum n bytes (i.e. strncmp()).
This commit is contained in:
@@ -1265,6 +1265,16 @@ void testEqualStrings(void)
|
||||
TEST_ASSERT_EQUAL_STRING("", "");
|
||||
}
|
||||
|
||||
void testEqualStringsLen(void)
|
||||
{
|
||||
const char *testString = "foobar";
|
||||
TEST_ASSERT_EQUAL_STRING_LEN(testString, testString, strlen(testString));
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 5);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("foo", testString, 3);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN(testString, foo, 3);
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("", "", 3);
|
||||
}
|
||||
|
||||
void testEqualStringsWithCarriageReturnsAndLineFeeds(void)
|
||||
{
|
||||
const char *testString = "foo\r\nbar";
|
||||
@@ -1283,6 +1293,13 @@ void testNotEqualString1(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStringLen1(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("foobar", "foobaz", 6);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualString2(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
@@ -1290,6 +1307,13 @@ void testNotEqualString2(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStringLen2(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("foo", "", 3);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualString3(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
@@ -1297,6 +1321,13 @@ void testNotEqualString3(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStringLen3(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("", "bar", 3);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualString4(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
@@ -1304,6 +1335,13 @@ void testNotEqualString4(void)
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualStringLen4(void)
|
||||
{
|
||||
EXPECT_ABORT_BEGIN
|
||||
TEST_ASSERT_EQUAL_STRING_LEN("bar\r", "bar\n", 4);
|
||||
VERIFY_FAILS_END
|
||||
}
|
||||
|
||||
void testNotEqualString5(void)
|
||||
{
|
||||
const char str1[] = { 0x41, 0x42, 0x03, 0x00 };
|
||||
|
||||
Reference in New Issue
Block a user