Completed
Branch feature/scrutinizer (5874ea)
by X
03:07
created

FloatParserTest::provideInvalidData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 50
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 32
nc 1
nop 0
dl 0
loc 50
rs 9.3333
c 0
b 0
f 0
1
<?php
2
3
namespace xKerman\Restricted\Test;
4
5
use PHPUnit\Framework\TestCase;
6
7
use xKerman\Restricted\FloatParser;
8
use xKerman\Restricted\Source;
9
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