#REFACTORING by exept
class: RegressionTests::NumberTest
removed: #testPrintf_More
changed: #testPrintf_Misc
--- a/RegressionTests__NumberTest.st Sat Dec 07 18:46:29 2019 +0100
+++ b/RegressionTests__NumberTest.st Sat Dec 07 21:11:34 2019 +0100
@@ -612,7 +612,9 @@
self assert:( PrintfScanf printf:'%d%' argument:20 ) = '20' .
self assert:( (20 printfPrintString:'%%') = '%' ).
- self assert:( (20 printfPrintString:c'\%') = '%' ).
+ "/ nobody knows what should happen...
+ "/ self assert:( (20 printfPrintString:'\%\') = '\' ).
+ "/ self assert:( (20 printfPrintString:'\%') = '%' ).
{
'%f' . Float NaN . 'nan' .
@@ -684,85 +686,6 @@
self assert:( (-2035065302 printfPrintString:'%d') = '-2035065302' ).
!
-testPrintf_More
- "/ additional test patterns from secrets of printf
-
- "/ verify that our printf generates the same string as the system-printf.
- "/ Checks of printfPrintString: are here to make sure, that the system's printf is doing it right...)
- self assert:( (20 printfPrintString:'%%%d') = '%20' ).
- self assert:( (20 printfPrintString:'%d%%') = '20%' ).
- "/ borland is wrong here
- (OperatingSystem isMSWINDOWSlike and:[ExternalAddress pointerSize == 4]) ifFalse:[
- self assert:( (20 printfPrintString:'%d%') = '20' ).
- ].
- self assert:( PrintfScanf printf:'%d%' argument:20 ) = '20' .
-
- self assert:( (20 printfPrintString:'%%') = '%' ).
- self assert:( (20 printfPrintString:c'\%') = '%' ).
-
- {
- '%f' . Float NaN . 'nan' .
- '%F' . Float NaN . 'NAN' .
- '%f' . Float infinity . 'inf' .
- '%F' . Float infinity . 'INF' .
- '%f' . Float negativeInfinity . '-inf' .
- '%F' . Float negativeInfinity . '-INF' .
-
- "/ The C99 standard specifies "[-]inf" or "[-]infinity" for infinity,
- "/ and a string starting with "nan" for NaN, in the case of f conversion,
- "/ and "[-]INF" or "[-]INFINITY" or "NAN*" in the case of F conversion
- '%+f' . Float NaN . '-nan' .
- '%+F' . Float NaN . '-NAN' .
- '%+f' . Float NaN negated . '+nan' .
- '%+F' . Float NaN negated . '+NAN' .
- '%+f' . Float infinity . '+inf' .
- '%+F' . Float infinity . '+INF' .
- '%+f' . Float negativeInfinity . '-inf' .
- '%+F' . Float negativeInfinity . '-INF' .
-
- '% f' . Float NaN . 'nan' . "/ not sure if that is reasonable (but printf does the same)
- '% F' . Float NaN . 'NAN' . "/ not sure if that is reasonable (but printf does the same)
- '% f' . Float infinity . ' inf' .
- '% F' . Float infinity . ' INF' .
- '% f' . Float negativeInfinity . '-inf' .
- '% F' . Float negativeInfinity . '-INF' .
- } inGroupsOf:3 do:[:fmt :val :expected|
- |printfGenerated stxGenerated|
-
- printfGenerated := val printfPrintString:fmt.
- stxGenerated := PrintfScanf printf:fmt argument:val.
- self assert:(printfGenerated = expected).
- "/ double check if the system's printf generates the same
- self assert:(stxGenerated = printfGenerated).
- ].
-
- #(
- '%r' 1234 'r'
- '%3r' 1234 ' r'
- '%-3r' 1234 'r '
- '%#r' 1234 'r'
- "/ '%v' 1234 'v'
- '%Id' 1234 'Id'
- '%%%d' 20 '%20'
- '%d%%' 20 '20%'
- '%d%' 20 '20'
- '%%a%%' 20 '%a%'
- ) inGroupsOf:3 do:[:fmt :val :expected|
- |printfGenerated stxGenerated|
-
- printfGenerated := val printfPrintString:fmt.
- stxGenerated := PrintfScanf printf:fmt argument:val.
- self assert:(stxGenerated = printfGenerated).
- self assert:(printfGenerated = expected).
- ].
-
- "/ more examples from "Secretes of printf"
- self assert:( (0 printfPrintString:'%d') = '0' ).
- self assert:( (-7 printfPrintString:'%d') = '-7' ).
- self assert:( (1560133635 printfPrintString:'%d') = '1560133635' ).
- self assert:( (-2035065302 printfPrintString:'%d') = '-2035065302' ).
-!
-
testPrintf_More2
"/ additional test patterns from secrets of printf
"/ https://www.cypress.com/file/54441/download