1 | <?php |
||
18 | class DecimalParserTest extends StringValueParserTest { |
||
19 | |||
20 | /** |
||
21 | * @deprecated since DataValues Common 0.3, just use getInstance. |
||
22 | */ |
||
23 | protected function getParserClass() { |
||
26 | |||
27 | /** |
||
28 | * @see ValueParserTestBase::getInstance |
||
29 | * |
||
30 | * @return DecimalParser |
||
31 | */ |
||
32 | protected function getInstance() { |
||
39 | |||
40 | /** |
||
41 | * @see ValueParserTestBase::validInputProvider |
||
42 | */ |
||
43 | public function validInputProvider() { |
||
44 | $argLists = array(); |
||
45 | |||
46 | $valid = array( |
||
47 | '0' => 0, |
||
48 | '-0' => 0, |
||
49 | '-00.00' => '-0.00', |
||
50 | '+00.00' => '+0.00', |
||
51 | '0001' => 1, |
||
52 | '+42' => 42, |
||
53 | '+01' => 01, |
||
54 | '9001' => 9001, |
||
55 | '-1' => -1, |
||
56 | '-42' => -42, |
||
57 | '.5' => 0.5, |
||
58 | '-.125' => -0.125, |
||
59 | '3.' => 3, |
||
60 | ',3,' => 3, |
||
61 | '2.125' => 2.125, |
||
62 | '2.1250' => '+2.1250', |
||
63 | '2.1250e0' => '+2.1250', |
||
64 | '2.1250e3' => '+2125.0', |
||
65 | '2.1250e+3' => '+2125.0', |
||
66 | '2.1250e-2' => '+0.021250', |
||
67 | '123e+3' => '+123000', |
||
68 | '123e-2' => '+1.23', |
||
69 | '-123e-5' => '-0.00123', |
||
70 | ' 5 ' => 5, |
||
71 | '100,000' => 100000, |
||
72 | '100 000' => 100000, |
||
73 | '100\'000' => 100000, |
||
74 | |||
75 | // U+000C (form feed) |
||
76 | "5\f" => 5, |
||
77 | // U+00A0 (non-break space) |
||
78 | "5\xC2\xA0200" => 5200, |
||
79 | // U+202F (narrow no-break space) |
||
80 | "5\xE2\x80\xAF300" => 5300, |
||
81 | ); |
||
82 | |||
83 | foreach ( $valid as $value => $expected ) { |
||
84 | // Because PHP turns them into ints using black magic |
||
85 | $value = (string)$value; |
||
86 | |||
87 | $expected = new DecimalValue( $expected ); |
||
88 | $argLists[] = array( $value, $expected ); |
||
89 | } |
||
90 | |||
91 | return $argLists; |
||
92 | } |
||
93 | |||
94 | /** |
||
95 | * @see StringValueParserTest::invalidInputProvider |
||
96 | */ |
||
97 | public function invalidInputProvider() { |
||
118 | |||
119 | public function testUnlocalization() { |
||
142 | |||
143 | public function splitDecimalExponentProvider() { |
||
159 | |||
160 | /** |
||
161 | * @dataProvider splitDecimalExponentProvider |
||
162 | */ |
||
163 | public function testSplitDecimalExponent( $valueString, $expectedDecimal, $expectedExponent ) { |
||
170 | |||
171 | public function applyDecimalExponentProvider() { |
||
178 | |||
179 | /** |
||
180 | * @dataProvider applyDecimalExponentProvider |
||
181 | */ |
||
182 | public function testApplyDecimalExponent( DecimalValue $decimal, $exponent, DecimalValue $expectedDecimal ) { |
||
188 | |||
189 | } |
||
190 |