C:\xampp2_not used\phpMyAdmin\vendor\bacon\bacon-qr-code\tests\BaconQrCode\Common\BitMatrixTest.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
 * BaconQrCode
 *
 * @link      http://github.com/Bacon/BaconQrCode For the canonical source repository
 * @copyright 2013 Ben 'DASPRiD' Scholzen
 * @license   http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
 */

namespace BaconQrCode\Common;

use 
PHPUnit_Framework_TestCase as TestCase;

class 
BitMatrixTest extends TestCase
{
    public function 
testGetSet()
    {
        
$matrix = new BitMatrix(33);
        
$this->assertEquals(33$matrix->getHeight());

        for (
$y 0$y 33$y++) {
            for (
$x 0$x 33$x++) {
                if (
$y $x === 0) {
                    
$matrix->set($x$y);
                }
            }
        }

        for (
$y 0$y 33$y++) {
            for (
$x 0$x 33$x++) {
                
$this->assertEquals($x $y === 0$matrix->get($x$y));
            }
        }
    }

    public function 
testSetRegion()
    {
        
$matrix = new BitMatrix(5);
        
$matrix->setRegion(1133);

        for (
$y 0$y 5$y++) {
            for (
$x 0$x 5$x++) {
                
$this->assertEquals($y >= && $y <= && $x >= && $x <= 3$matrix->get($x$y));
            }
        }
    }

    public function 
testRectangularMatrix()
    {
        
$matrix = new BitMatrix(7520);
        
$this->assertEquals(75$matrix->getWidth());
        
$this->assertEquals(20$matrix->getHeight());

        
$matrix->set(100);
        
$matrix->set(111);
        
$matrix->set(502);
        
$matrix->set(513);
        
$matrix->flip(744);
        
$matrix->flip(05);

        
$this->assertTrue($matrix->get(100));
        
$this->assertTrue($matrix->get(111));
        
$this->assertTrue($matrix->get(502));
        
$this->assertTrue($matrix->get(513));
        
$this->assertTrue($matrix->get(744));
        
$this->assertTrue($matrix->get(05));

        
$matrix->flip(502);
        
$matrix->flip(513);

        
$this->assertFalse($matrix->get(502));
        
$this->assertFalse($matrix->get(513));
    }

    public function 
testRectangularSetRegion()
    {
        
$matrix = new BitMatrix(320240);
        
$this->assertEquals(320$matrix->getWidth());
        
$this->assertEquals(240$matrix->getHeight());

        
$matrix->setRegion(105228012);

        for (
$y 0$y 240$y++) {
            for (
$x 0$x 320$x++) {
                
$this->assertEquals($y >= 22 && $y 34 && $x >= 105 && $x 185$matrix->get($x$y));
            }
        }
    }

    public function 
testGetRow()
    {
        
$matrix = new BitMatrix(1025);

        for (
$x 0$x 102$x++) {
            if (
$x === 0) {
                
$matrix->set($x2);
            }
        }

        
$array1 $matrix->getRow(2null);
        
$this->assertEquals(102$array1->getSize());

        
$array2 = new BitArray(60);
        
$array2 $matrix->getRow(2$array2);
        
$this->assertEquals(102$array2->getSize());

        
$array3 = new BitArray(200);
        
$array3 $matrix->getRow(2$array3);
        
$this->assertEquals(200$array3->getSize());

        for (
$x 0$x 102$x++) {
            
$on = ($x === 0);

            
$this->assertEquals($on$array1->get($x));
            
$this->assertEquals($on$array2->get($x));
            
$this->assertEquals($on$array3->get($x));
        }
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586