1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-09-28 19:05:55 +08:00
ULib/tests/base/ok/sprintf.ok
stefanocasazza 4a5c999ac7 fix
2017-08-22 16:44:46 +02:00

102 lines
3.2 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%.4x: `0012'
%04x: `0012'
%4.4x: `0012'
%04.4x: `0012'
%4.3x: ` 012'
%04.3x: ` 012'
%.*x: `0012'
%0*x: `0012'
%*.*x: `0012'
%0*.*x: `0012'
bad format: "%K"
nil pointer (padded): "(nil)"
decimal negative: "-2345"
octal negative: "37777773327"
hex negative: "fffff6d7"
long decimal number: "-123456"
zero-padded LDN: "-000123456"
space-padded LDN: " -123456"
left-adjusted SLDN: "-123456 "
zero-padded string: " Hi, Z."
left-adjusted Z string: "Hi, Z. "
space-padded string: " Hi, Z."
left-adjusted S string: "Hi, Z. "
null string: "(null)"
limited string: "Good morning, Doctor C"
e-style >= 1: "1.234000e+01"
e-style >= .1: "1.234000e-01"
e-style < .1: "1.234000e-03"
e-style big: "1.000000000000000000000000000000000000000000000000000000000000e+20"
e-style == .1: "1.000000e-01"
f-style >= 1: "12.340000"
f-style >= .1: "0.123400"
f-style < .1: "0.001234"
g-style >= 1: "12.34"
g-style >= .1: "0.1234"
g-style < .1: "0.001234"
g-style big: "100000000000000000000"
0.10000
0.10000
x0.5000x
0x001
something really insane: 1.0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
5.87747175411143754e-39
4.94066e-324
| 0.0000 | 0.0000e+00 | 0 |
| 1.0000 | 1.0000e+00 | 1 |
| -1.0000 | -1.0000e+00 | -1 |
| 100.0000 | 1.0000e+02 | 100 |
| 1000.0000 | 1.0000e+03 | 1000 |
| 10000.0000 | 1.0000e+04 | 1e+04 |
| 12345.0000 | 1.2345e+04 | 1.234e+04 |
| 100000.0000 | 1.0000e+05 | 1e+05 |
| 123456.0000 | 1.2346e+05 | 1.235e+05 |
snprintf ("%30s", "foo") == 30, " foo"
snprintf ("%.999u", 10) = 999
Formatted output test
prefix 6d 6o 6x 6X 6u
%-+00 |-123 |377 |ff |FF |4294967295 |
%-+0 |-123 |377 |ff |FF |4294967295 |
%-+0 |-123 |377 |ff |FF |4294967295 |
%-+ |-123 |377 |ff |FF |4294967295 |
%-00 |-123 |377 |ff |FF |4294967295 |
%-0 |-123 |377 |ff |FF |4294967295 |
%-0 |-123 |377 |ff |FF |4294967295 |
%- |-123 |377 |ff |FF |4294967295 |
%+00 |-00123 |000377 |0000ff |0000FF |4294967295 |
%+0 |-00123 |000377 |0000ff |0000FF |4294967295 |
%+0 |-00123 |000377 |0000ff |0000FF |4294967295 |
%+ | -123 | 377 | ff | FF |4294967295 |
%00 |-00123 |000377 |0000ff |0000FF |4294967295 |
%0 |-00123 |000377 |0000ff |0000FF |4294967295 |
%0 |-00123 |000377 |0000ff |0000FF |4294967295 |
% | -123 | 377 | ff | FF |4294967295 |
(null)
(null)
1234567.800000 should be 1234567.800000
123.456 should be 123.456
10 should be 10
0.02 should be 0.02
Test ok.
sprintf (buf, "%07llo", 040000000000ll) = 40000000000
printf ("%c", 257) = 
printf ("%hu", 65537) = 1
--- Should be no further output. ---