| 1 | <?php |
||
| 10 | class FloatParserTest extends TestCase |
||
| 11 | { |
||
| 12 | public function provideInvalidData() |
||
| 13 | { |
||
| 14 | return [ |
||
| 15 | 'empty string' => [ |
||
| 16 | 'input' => '', |
||
| 17 | ], |
||
| 18 | 'not integer' => [ |
||
| 19 | 'input' => 'N;', |
||
| 20 | ], |
||
| 21 | 'missing tag' => [ |
||
| 22 | 'input' => ':0;', |
||
| 23 | ], |
||
| 24 | 'missing value' => [ |
||
| 25 | 'input' => 'd:;', |
||
| 26 | ], |
||
| 27 | 'missing semicolon' => [ |
||
| 28 | 'input' => 'd:0', |
||
| 29 | ], |
||
| 30 | 'sign only' => [ |
||
| 31 | 'input' => 'd:+;', |
||
| 32 | ], |
||
| 33 | 'multiple sign' => [ |
||
| 34 | 'input' => 'd:++6;', |
||
| 35 | ], |
||
| 36 | 'dot only' => [ |
||
| 37 | 'input' => 'd:.;', |
||
| 38 | ], |
||
| 39 | 'dot and exponential' => [ |
||
| 40 | 'input' => 'd:.E;', |
||
| 41 | ], |
||
| 42 | 'dot and exponential part' => [ |
||
| 43 | 'input' => 'd:.E1;', |
||
| 44 | ], |
||
| 45 | 'infinity with plus' => [ |
||
| 46 | 'input' => 'd:+INF;', |
||
| 47 | ], |
||
| 48 | 'nan with plus' => [ |
||
| 49 | 'input' => 'd:+NAN;', |
||
| 50 | ], |
||
| 51 | 'nan with plus' => [ |
||
| 52 | 'input' => 'd:-NAN;', |
||
| 53 | ], |
||
| 54 | 'float in exponential part' => [ |
||
| 55 | 'input' => 'd:1.0e1.0;', |
||
| 56 | ], |
||
| 57 | 'only exponential part' => [ |
||
| 58 | 'input' => 'd:e1;' |
||
| 59 | ], |
||
| 60 | ]; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @covers \xKerman\Restricted\FloatParser |
||
| 65 | * @dataProvider provideInvalidData |
||
| 66 | * @expectedException \xKerman\Restricted\UnserializeFailedException |
||
| 67 | */ |
||
| 68 | public function testParseFailure($input) |
||
| 69 | { |
||
| 70 | $source = new Source($input); |
||
| 71 | $parser = new FloatParser(); |
||
| 72 | $parser->parse($source); |
||
| 73 | } |
||
| 74 | } |
||
| 75 |