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

FloatParserTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 65
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provideInvalidData() 0 50 1
A testParseFailure() 0 6 1
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