tests/unit/cbprintf: test %p with NULL and justification
Make sure the "(nil)" string is properly aligned. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
0e9a37161e
commit
e4e5e01101
1 changed files with 10 additions and 0 deletions
|
@ -944,6 +944,11 @@ static void test_p(void)
|
|||
rc = rawprf("/%12p/", ptr);
|
||||
zassert_equal(rc, 14, NULL);
|
||||
zassert_equal(strncmp("/ 0xcafe21/", buf, rc), 0, NULL);
|
||||
|
||||
reset_out();
|
||||
rc = rawprf("/%12p/", NULL);
|
||||
zassert_equal(rc, 14, NULL);
|
||||
zassert_equal(strncmp("/ (nil)/", buf, rc), 0, NULL);
|
||||
}
|
||||
|
||||
reset_out();
|
||||
|
@ -951,6 +956,11 @@ static void test_p(void)
|
|||
zassert_equal(rc, 14, NULL);
|
||||
zassert_equal(strncmp("/0xcafe21 /", buf, rc), 0, NULL);
|
||||
|
||||
reset_out();
|
||||
rc = rawprf("/%-12p/", NULL);
|
||||
zassert_equal(rc, 14, NULL);
|
||||
zassert_equal(strncmp("/(nil) /", buf, rc), 0, NULL);
|
||||
|
||||
/* Nano doesn't support zero-padding of pointer values.
|
||||
*/
|
||||
if (!IS_ENABLED(CONFIG_CBPRINTF_NANO)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue