Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit ecb4357

Browse files
committed
tests/basics: Move string-modulo-format int tests to dedicated file.
1 parent b154468 commit ecb4357

File tree

2 files changed

+34
-32
lines changed

2 files changed

+34
-32
lines changed

tests/basics/string_format_modulo.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,38 +33,6 @@
3333
print("%c" % 'a')
3434
print("%10s" % 'abc')
3535
print("%-10s" % 'abc')
36-
print("%d" % 10)
37-
print("%+d" % 10)
38-
print("% d" % 10)
39-
print("%d" % -10)
40-
print("%d" % True)
41-
print("%i" % -10)
42-
print("%i" % True)
43-
print("%u" % -10)
44-
print("%u" % True)
45-
print("%x" % 18)
46-
print("%o" % 18)
47-
print("%X" % 18)
48-
print("%#x" % 18)
49-
print("%#X" % 18)
50-
print("%#6o" % 18)
51-
print("%#6x" % 18)
52-
print("%#06x" % 18)
53-
54-
print("%*d" % (5, 10))
55-
print("%*.*d" % (2, 2, 20))
56-
print("%*.*d" % (5, 8, 20))
57-
58-
print(">%8.4d<" % -12)
59-
print(">% 8.4d<" % -12)
60-
print(">%+8.4d<" % 12)
61-
print(">%+8.4d<" % -12)
62-
print(">%08.4d<" % -12)
63-
print(">%08.4d<" % 12)
64-
print(">%-8.4d<" % -12)
65-
print(">%-08.4d<" % -12)
66-
print(">%-+08.4d<" % -12)
67-
print(">%-+08.4d<" % 12)
6836

6937
# Should be able to print dicts; in this case they aren't used
7038
# to lookup keywords in formats like %(foo)s

tests/basics/string_format_modulo_int.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,39 @@
11
# test string modulo formatting with int values
22

3+
# basic cases
4+
print("%d" % 10)
5+
print("%+d" % 10)
6+
print("% d" % 10)
7+
print("%d" % -10)
8+
print("%d" % True)
9+
print("%i" % -10)
10+
print("%i" % True)
11+
print("%u" % -10)
12+
print("%u" % True)
13+
print("%x" % 18)
14+
print("%o" % 18)
15+
print("%X" % 18)
16+
print("%#x" % 18)
17+
print("%#X" % 18)
18+
print("%#6o" % 18)
19+
print("%#6x" % 18)
20+
print("%#06x" % 18)
21+
22+
# with *
23+
print("%*d" % (5, 10))
24+
print("%*.*d" % (2, 2, 20))
25+
print("%*.*d" % (5, 8, 20))
26+
27+
# precision
28+
for val in (-12, 12):
29+
print(">%8.4d<" % val)
30+
print(">% 8.4d<" % val)
31+
print(">%+8.4d<" % val)
32+
print(">%08.4d<" % val)
33+
print(">%-8.4d<" % val)
34+
print(">%-08.4d<" % val)
35+
print(">%-+08.4d<" % val)
36+
337
# test + option with various amount of padding
438
for pad in ('', ' ', '0'):
539
for n in (1, 2, 3):

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy