@@ -22,6 +22,46 @@ class QRMatrixTest extends QRTestAbstract{
2222
2323 protected $ version = 7 ;
2424
25+ /**
26+ * @link http://www.thonky.com/qr-code-tutorial/format-version-tables
27+ */
28+ const VERSION_REF = [
29+ 7 => '000111110010010100 ' ,
30+ 8 => '001000010110111100 ' ,
31+ 9 => '001001101010011001 ' ,
32+ 10 => '001010010011010011 ' ,
33+ 11 => '001011101111110110 ' ,
34+ 12 => '001100011101100010 ' ,
35+ 13 => '001101100001000111 ' ,
36+ 14 => '001110011000001101 ' ,
37+ 15 => '001111100100101000 ' ,
38+ 16 => '010000101101111000 ' ,
39+ 17 => '010001010001011101 ' ,
40+ 18 => '010010101000010111 ' ,
41+ 19 => '010011010100110010 ' ,
42+ 20 => '010100100110100110 ' ,
43+ 21 => '010101011010000011 ' ,
44+ 22 => '010110100011001001 ' ,
45+ 23 => '010111011111101100 ' ,
46+ 24 => '011000111011000100 ' ,
47+ 25 => '011001000111100001 ' ,
48+ 26 => '011010111110101011 ' ,
49+ 27 => '011011000010001110 ' ,
50+ 28 => '011100110000011010 ' ,
51+ 29 => '011101001100111111 ' ,
52+ 30 => '011110110101110101 ' ,
53+ 31 => '011111001001010000 ' ,
54+ 32 => '100000100111010101 ' ,
55+ 33 => '100001011011110000 ' ,
56+ 34 => '100010100010111010 ' ,
57+ 35 => '100011011110011111 ' ,
58+ 36 => '100100101100001011 ' ,
59+ 37 => '100101010000101110 ' ,
60+ 38 => '100110101001100100 ' ,
61+ 39 => '100111010101000001 ' ,
62+ 40 => '101000110001101001 '
63+ ];
64+
2565 /**
2666 * @var \chillerlan\QRCode\Data\QRMatrix
2767 */
@@ -61,6 +101,15 @@ public function testVersion(){
61101 $ this ->assertSame ($ this ->version , $ this ->matrix ->version ());
62102 }
63103
104+ public function testVersionPattern () {
105+ foreach (self ::VERSION_REF as $ version => $ mask ) {
106+ $ hexRef = base_convert (self ::VERSION_REF [$ version ],2 ,16 );
107+ $ hexImpl = dechex (QRMatrix::versionPattern[$ version ]);
108+
109+ $ this ->assertEquals ($ hexRef , $ hexImpl );
110+ }
111+ }
112+
64113 public function testECC (){
65114 $ this ->assertSame (QRCode::ECC_L , $ this ->matrix ->eccLevel ());
66115 }
0 commit comments