From ecb4357fe1c417e7349a56affcee5e2ccdf0d421 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 15 Mar 2017 17:34:47 +1100 Subject: tests/basics: Move string-modulo-format int tests to dedicated file. --- tests/basics/string_format_modulo_int.py | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'tests/basics/string_format_modulo_int.py') diff --git a/tests/basics/string_format_modulo_int.py b/tests/basics/string_format_modulo_int.py index c97bca9bd..d1f29db22 100644 --- a/tests/basics/string_format_modulo_int.py +++ b/tests/basics/string_format_modulo_int.py @@ -1,5 +1,39 @@ # test string modulo formatting with int values +# basic cases +print("%d" % 10) +print("%+d" % 10) +print("% d" % 10) +print("%d" % -10) +print("%d" % True) +print("%i" % -10) +print("%i" % True) +print("%u" % -10) +print("%u" % True) +print("%x" % 18) +print("%o" % 18) +print("%X" % 18) +print("%#x" % 18) +print("%#X" % 18) +print("%#6o" % 18) +print("%#6x" % 18) +print("%#06x" % 18) + +# with * +print("%*d" % (5, 10)) +print("%*.*d" % (2, 2, 20)) +print("%*.*d" % (5, 8, 20)) + +# precision +for val in (-12, 12): + print(">%8.4d<" % val) + print(">% 8.4d<" % val) + print(">%+8.4d<" % val) + print(">%08.4d<" % val) + print(">%-8.4d<" % val) + print(">%-08.4d<" % val) + print(">%-+08.4d<" % val) + # test + option with various amount of padding for pad in ('', ' ', '0'): for n in (1, 2, 3): -- cgit v1.2.3