Skip to content

Commit

Permalink
tests:kernel: added tests for printk left justifier
Browse files Browse the repository at this point in the history
Added test case for printk the '-' indicator in format string
(left justifier).

Jira: ZEP-1599

Signed-off-by: Sharron LIU <[email protected]>
  • Loading branch information
Sharron LIU committed May 8, 2017
1 parent b7f6aaa commit dca079d
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tests/kernel/common/src/printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ char *expected = "22 113 10000 32768 40000 22\n"
"-42 -42 -042 -0000042\n"
"42 42 42 42\n"
"42 42 0042 00000042\n"
"255 42 abcdef 0x0000002a 42\n"
;


Expand Down Expand Up @@ -71,6 +72,7 @@ void printk_test(void)
printk("%d %02d %04d %08d\n", -42, -42, -42, -42);
printk("%u %2u %4u %8u\n", 42, 42, 42, 42);
printk("%u %02u %04u %08u\n", 42, 42, 42, 42);
printk("%-8u%-6d%-4x%-2p%8d\n", 0xFF, 42, 0xABCDEF, (char *)42, 42);

ram_console[pos] = '\0';
zassert_true((strcmp(ram_console, expected) == 0), "printk failed");
Expand All @@ -97,7 +99,9 @@ void printk_test(void)
"%u %2u %4u %8u\n", 42, 42, 42, 42);
count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%u %02u %04u %08u\n", 42, 42, 42, 42);

count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%-8u%-6d%-4x%-2p%8d\n",
0xFF, 42, 0xABCDEF, (char *)42, 42);
ram_console[count] = '\0';
zassert_true((strcmp(ram_console, expected) == 0), "snprintk failed");
}

0 comments on commit dca079d

Please sign in to comment.