@@ -102,7 +102,7 @@ public function test_validate_success($value, $min, $max, $decpoint = '.')
102
102
public function valueProvider ()
103
103
{
104
104
return [
105
- // $value, $expect, $roundto, $decpoint, $thousands, $trimzeros, $prefix='', $postfix='', $engineering = false
105
+ // $value, $expect, $roundto, $decpoint, $thousands, $trimzeros, $prefix='', $postfix='', $engineering = false, $format = ''
106
106
['5000 ' , '5 000,00 ' , '2 ' , ', ' , ' ' , false ],
107
107
['5000 ' , '5 000 ' , '2 ' , ', ' , ' ' , true ],
108
108
['5000 ' , '5 000 ' , '0 ' , ', ' , ' ' , false ],
@@ -149,6 +149,21 @@ public function valueProvider()
149
149
['1e15 ' , '1000 ' . "\xE2\x80\xAF" . 'T ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ],
150
150
['1e-21 ' , '0.001 ' . "\xE2\x80\xAF" . 'a ' , '-1 ' , ', ' , ' ' , true , '' , '' , true ],
151
151
152
+ // test format string
153
+ // invalid or empty format (ignored)
154
+ ['5000 ' , '5 000 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '' ],
155
+ ['5000 ' , '5 000.00 ' , '2 ' , '. ' , ' ' , false , '' , '' , false , '%s ' ],
156
+ ['5000 ' , '5 000.00 ' , '2 ' , '. ' , ' ' , false , '' , '' , false , '%1$d ' ],
157
+ ['5000 ' , '5 000.00 ' , '2 ' , '. ' , ' ' , false , '' , '' , false , '%04d%02d%02d ' ],
158
+ // valid format
159
+ ['1.7 ' , '1.70 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '%01.2f ' ],
160
+ ['1.7 ' , '1.70 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '%01.2F ' ],
161
+ ['1.7 ' , '0001 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , "%'.04d " ],
162
+ ['15 ' , '1111 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '%04b ' ],
163
+ ['362525200 ' , '3.625e+8 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '%.3e ' ],
164
+ ['362525200 ' , '3.625E+8 ' , '-1 ' , '. ' , ' ' , true , '' , '' , false , '%.3E ' ],
165
+ ['1.7 ' , '1 ' , '2 ' , '. ' , ' ' , false , '' , '' , false , '%u ' ],
166
+
152
167
];
153
168
}
154
169
@@ -158,7 +173,8 @@ public function valueProvider()
158
173
public function test_renderValue (
159
174
$ value , $ expect , $ roundto , $ decpoint ,
160
175
$ thousands , $ trimzeros ,
161
- $ prefix = '' , $ postfix = '' , $ engineering = false
176
+ $ prefix = '' , $ postfix = '' , $ engineering = false ,
177
+ $ format = ''
162
178
)
163
179
{
164
180
$ decimal = new Decimal ([
@@ -168,7 +184,8 @@ public function test_renderValue(
168
184
'trimzeros ' => $ trimzeros ,
169
185
'prefix ' => $ prefix ,
170
186
'postfix ' => $ postfix ,
171
- 'engineering ' => $ engineering
187
+ 'engineering ' => $ engineering ,
188
+ 'format ' => $ format
172
189
]);
173
190
$ R = new \Doku_Renderer_xhtml ();
174
191
$ R ->doc = '' ;
0 commit comments