@@ -188,21 +188,26 @@ function compareNumbers($actual, $input, $column, $fieldScale, $formatDecimal =
188
188
$ matched = false ;
189
189
if ($ actual === $ input ) {
190
190
$ matched = true ;
191
- trace ("$ actual, $ input \n" );
191
+ trace ("Matched: $ actual, $ input \n" );
192
192
} else {
193
193
// When $formatDecimal is negative, that means no formatting done
194
194
// Otherwise, if $formatDecimal > $fieldScale, will show $fieldScale decimal digits
195
195
if ($ formatDecimal >= 0 ) {
196
196
$ numDecimals = ($ formatDecimal > $ fieldScale ) ? $ fieldScale : $ formatDecimal ;
197
+ $ expected = number_format ($ input , $ numDecimals );
197
198
} else {
198
- $ numDecimals = $ fieldScale ;
199
+ $ expected = number_format ($ input , $ fieldScale );
200
+ if (abs ($ input ) < 1 ) {
201
+ // Since no formatting, the leading zero should not be there
202
+ trace ("Drop leading zero of $ input-- " );
203
+ $ expected = str_replace ('0. ' , '. ' , $ expected );
204
+ }
199
205
}
200
- $ expected = number_format ($ input , $ numDecimals );
201
- trace ("$ actual, $ expected \n" );
206
+ trace ("With number_format: $ actual, $ expected \n" );
202
207
if ($ actual === $ expected ) {
203
208
$ matched = true ;
204
209
} else {
205
- echo "For $ column: expected $ expected but the value is $ actual \n" ;
210
+ echo "For $ column ( $ formatDecimal ) : expected $ expected ( $ input ) but the value is $ actual \n" ;
206
211
}
207
212
}
208
213
return $ matched ;
@@ -265,7 +270,7 @@ function getOutputParam($conn, $storedProcName, $inputValue, $prec, $scale, $ino
265
270
$ paramType = PDO ::PARAM_STR | PDO ::PARAM_INPUT_OUTPUT ;
266
271
267
272
// For inout parameters the input type should match the output one
268
- $ outString = '0.0 ' ;
273
+ $ outString = '0.0 ' ;
269
274
} else {
270
275
$ paramType = PDO ::PARAM_STR ;
271
276
}
0 commit comments