From be7d02ebdde5c30d664496c57c3265469907004e Mon Sep 17 00:00:00 2001 From: Siteshwar Vashisht Date: Sun, 3 Mar 2013 00:45:34 +0530 Subject: [PATCH] Added test cases for printf builtin --- builtin_printf.cpp | 6 +++--- tests/printf.err | 0 tests/printf.in | 19 +++++++++++++++++++ tests/printf.out | 13 +++++++++++++ tests/printf.status | 1 + 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 tests/printf.err create mode 100644 tests/printf.in create mode 100644 tests/printf.out create mode 100644 tests/printf.status diff --git a/builtin_printf.cpp b/builtin_printf.cpp index e5f0e4ae1..9ff8b363d 100644 --- a/builtin_printf.cpp +++ b/builtin_printf.cpp @@ -52,7 +52,7 @@ #include "common.h" -// This file has bee imported from source code of printf command in GNU Coreutils version 6.9 +// This file has been imported from source code of printf command in GNU Coreutils version 6.9 /* The official name of this program (e.g., no `g' prefix). */ #define PROGRAM_NAME "printf" @@ -312,7 +312,7 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion switch (conversion) { - case L'd': case L'i': case L'o': case L'u': case L'x': case L'X': + case L'd': case L'i': length_modifier = PRIdMAX; length_modifier_len = sizeof PRIdMAX - 2; break; @@ -322,7 +322,7 @@ static void print_direc (const wchar_t *start, size_t length, wchar_t conversion length_modifier = L"L"; length_modifier_len = 1; break; - case L's': + case L's': case L'u': length_modifier = L"l"; length_modifier_len = 1; break; diff --git a/tests/printf.err b/tests/printf.err new file mode 100644 index 000000000..e69de29bb diff --git a/tests/printf.in b/tests/printf.in new file mode 100644 index 000000000..f06694691 --- /dev/null +++ b/tests/printf.in @@ -0,0 +1,19 @@ +printf "Hello %d %i %f %F %g %G\n" 1 2 3 4 5 6 + +printf "%x %X %o %u\n" 10 11 8 -1 +printf "%a %A\n" 14 15 + +printf "%c %s\n" a hello +printf "%e %E\n" 5 6 + +printf "%20d\n" 50 +printf "%-20d%d\n" 5 10 + +printf "%*d\n" 10 100 + +printf "%%\"\\\n" +printf "%s\b%s\n" x y +printf "abc\rdef\n" +printf "Msg1\fMsg2\n" +printf "foo\vbar\vbaz\n" +printf "\111 \x50" # \u0051 \U00000052 diff --git a/tests/printf.out b/tests/printf.out new file mode 100644 index 000000000..b24cfc7b0 --- /dev/null +++ b/tests/printf.out @@ -0,0 +1,13 @@ +Hello 1 2 3.000000 4.000000 5 6 +a B 10 18446744073709551615 +0xep+0 0XFP+0 +a hello +5.000000e+00 6.000000E+00 + 50 +5 10 + 100 +%"\nxy +abc def +Msg1 Msg2 +foo bar baz +I P \ No newline at end of file diff --git a/tests/printf.status b/tests/printf.status new file mode 100644 index 000000000..573541ac9 --- /dev/null +++ b/tests/printf.status @@ -0,0 +1 @@ +0