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:
Nicolas Pitre 2020-11-14 23:12:53 -05:00 committed by Carles Cufí
commit e4e5e01101

View file

@ -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)) {