PluginProbe ʕ •ᴥ•ʔ
Booking for Appointments and Events Calendar – Amelia / 2.4.4
Booking for Appointments and Events Calendar – Amelia v2.4.4
2.4.4 2.4.3 2.4.2 2.4.1 2.4 trunk 1.2.1 1.2.10 1.2.11 1.2.12 1.2.13 1.2.14 1.2.15 1.2.16 1.2.17 1.2.18 1.2.19 1.2.2 1.2.20 1.2.21 1.2.22 1.2.23 1.2.24 1.2.25 1.2.26 1.2.27 1.2.28 1.2.29 1.2.3 1.2.30 1.2.31 1.2.32 1.2.33 1.2.34 1.2.35 1.2.36 1.2.37 1.2.38 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.1.3 2.2 2.2.1 2.3
ameliabooking / vendor / bacon / bacon-qr-code / test / Common / FormatInformationTest.php
ameliabooking / vendor / bacon / bacon-qr-code / test / Common Last commit date
BitArrayTest.php 8 months ago BitMatrixTest.php 8 months ago BitUtilsTest.php 8 months ago ErrorCorrectionLevelTest.php 8 months ago FormatInformationTest.php 8 months ago ModeTest.php 8 months ago ReedSolomonCodecTest.php 8 months ago VersionTest.php 8 months ago
FormatInformationTest.php
95 lines
1 <?php
2 declare(strict_types = 1);
3
4 namespace BaconQrCodeTest\Common;
5
6 use BaconQrCode\Common\ErrorCorrectionLevel;
7 use BaconQrCode\Common\FormatInformation;
8 use PHPUnit\Framework\TestCase;
9
10 class FormatInformationTest extends TestCase
11 {
12 private const MASKED_TEST_FORMAT_INFO = 0x2bed;
13 private const UNMAKSED_TEST_FORMAT_INFO = self::MASKED_TEST_FORMAT_INFO ^ 0x5412;
14
15 public function testBitsDiffering() : void
16 {
17 $this->assertSame(0, FormatInformation::numBitsDiffering(1, 1));
18 $this->assertSame(1, FormatInformation::numBitsDiffering(0, 2));
19 $this->assertSame(2, FormatInformation::numBitsDiffering(1, 2));
20 $this->assertEquals(32, FormatInformation::numBitsDiffering(-1, 0));
21 }
22
23 public function testDecode() : void
24 {
25 $expected = FormatInformation::decodeFormatInformation(
26 self::MASKED_TEST_FORMAT_INFO,
27 self::MASKED_TEST_FORMAT_INFO
28 );
29
30 $this->assertNotNull($expected);
31 $this->assertSame(7, $expected->getDataMask());
32 $this->assertSame(ErrorCorrectionLevel::Q(), $expected->getErrorCorrectionLevel());
33
34 $this->assertEquals(
35 $expected,
36 FormatInformation::decodeFormatInformation(
37 self::UNMAKSED_TEST_FORMAT_INFO,
38 self::MASKED_TEST_FORMAT_INFO
39 )
40 );
41 }
42
43 public function testDecodeWithBitDifference() : void
44 {
45 $expected = FormatInformation::decodeFormatInformation(
46 self::MASKED_TEST_FORMAT_INFO,
47 self::MASKED_TEST_FORMAT_INFO
48 );
49
50 $this->assertEquals(
51 $expected,
52 FormatInformation::decodeFormatInformation(
53 self::MASKED_TEST_FORMAT_INFO ^ 0x1,
54 self::MASKED_TEST_FORMAT_INFO ^ 0x1
55 )
56 );
57 $this->assertEquals(
58 $expected,
59 FormatInformation::decodeFormatInformation(
60 self::MASKED_TEST_FORMAT_INFO ^ 0x3,
61 self::MASKED_TEST_FORMAT_INFO ^ 0x3
62 )
63 );
64 $this->assertEquals(
65 $expected,
66 FormatInformation::decodeFormatInformation(
67 self::MASKED_TEST_FORMAT_INFO ^ 0x7,
68 self::MASKED_TEST_FORMAT_INFO ^ 0x7
69 )
70 );
71 $this->assertNull(
72 FormatInformation::decodeFormatInformation(
73 self::MASKED_TEST_FORMAT_INFO ^ 0xf,
74 self::MASKED_TEST_FORMAT_INFO ^ 0xf
75 )
76 );
77 }
78
79 public function testDecodeWithMisRead() : void
80 {
81 $expected = FormatInformation::decodeFormatInformation(
82 self::MASKED_TEST_FORMAT_INFO,
83 self::MASKED_TEST_FORMAT_INFO
84 );
85
86 $this->assertEquals(
87 $expected,
88 FormatInformation::decodeFormatInformation(
89 self::MASKED_TEST_FORMAT_INFO ^ 0x3,
90 self::MASKED_TEST_FORMAT_INFO ^ 0xf
91 )
92 );
93 }
94 }
95