ztest: Add macros for comparing strings
These macros allows us to compare strings in a simpler way. Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
This commit is contained in:
parent
4d2e46478d
commit
a35d5e7851
3 changed files with 65 additions and 0 deletions
|
@ -36,6 +36,23 @@ ZTEST(framework_tests, test_assert_mem_equal)
|
|||
zassert_mem_equal(actual, expected, sizeof(expected), NULL);
|
||||
}
|
||||
|
||||
ZTEST(framework_tests, test_assert_str_equal)
|
||||
{
|
||||
const char *s1 = "asdf";
|
||||
const char s2[] = {'a', 's', 'd', 'f', '\0'};
|
||||
|
||||
zassert_str_equal(s1, s2);
|
||||
}
|
||||
|
||||
ZTEST_EXPECT_FAIL(framework_tests, test_assert_str_equal_fail);
|
||||
ZTEST(framework_tests, test_assert_str_equal_fail)
|
||||
{
|
||||
const char *s1 = "asdf";
|
||||
const char s2[] = {'a', 's', 'd', 'f', 'q', '\0'};
|
||||
|
||||
zassert_str_equal(s1, s2);
|
||||
}
|
||||
|
||||
ZTEST_EXPECT_SKIP(framework_tests, test_skip_config);
|
||||
ZTEST(framework_tests, test_skip_config)
|
||||
{
|
||||
|
|
|
@ -172,3 +172,20 @@ ZTEST(expect, test_fail_expect_between_inclusive)
|
|||
zexpect_between_inclusive(5, 0, 4);
|
||||
zexpect_between_inclusive(5, 6, 10);
|
||||
}
|
||||
|
||||
ZTEST(expect, test_expect_str_equal)
|
||||
{
|
||||
const char *s1 = "asdf";
|
||||
const char s2[] = {'a', 's', 'd', 'f', '\0'};
|
||||
|
||||
zexpect_str_equal(s1, s2);
|
||||
}
|
||||
|
||||
ZTEST_EXPECT_FAIL(expect, test_expect_str_equal_fail);
|
||||
ZTEST(expect, test_expect_str_equal_fail)
|
||||
{
|
||||
const char *s1 = "asdf";
|
||||
const char s2[] = {'a', 's', 'd', 'f', 'q', '\0'};
|
||||
|
||||
zexpect_str_equal(s1, s2);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue