* grub-core/kern/misc.c (grub_vsnprintf_real): Handle %% properly.
* tests/printf_unit_test.c (printf_test): Add %% tests. Reported by: Paulo Flabiano Smorigo.
This commit is contained in:
parent
af3b06be14
commit
148f100768
3 changed files with 26 additions and 1 deletions
|
@ -21,13 +21,26 @@
|
|||
#include <grub/test.h>
|
||||
#include <grub/misc.h>
|
||||
|
||||
#define MSG "printf test failed"
|
||||
#define MSG "printf test failed: %s, %s", real, expected
|
||||
|
||||
static void
|
||||
printf_test (void)
|
||||
{
|
||||
char real[512];
|
||||
char expected[512];
|
||||
|
||||
grub_snprintf (real, sizeof (real), "%d%%", 10);
|
||||
snprintf (expected, sizeof (expected), "%d%%", 10);
|
||||
grub_test_assert (strcmp (real, expected) == 0, MSG);
|
||||
|
||||
grub_snprintf (real, sizeof (real), "%d %%", 10);
|
||||
snprintf (expected, sizeof (expected), "%d %%", 10);
|
||||
grub_test_assert (strcmp (real, expected) == 0, MSG);
|
||||
|
||||
grub_snprintf (real, sizeof (real), "%%");
|
||||
snprintf (expected, sizeof (expected), "%%");
|
||||
grub_test_assert (strcmp (real, expected) == 0, MSG);
|
||||
|
||||
grub_snprintf (real, sizeof (real), "%d %d %d", 1, 2, 3);
|
||||
snprintf (expected, sizeof (expected), "%d %d %d", 1, 2, 3);
|
||||
grub_test_assert (strcmp (real, expected) == 0, MSG);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue