summaryrefslogtreecommitdiff
path: root/vendor/chillerlan/php-qrcode/tests/Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/chillerlan/php-qrcode/tests/Helpers')
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php53
-rw-r--r--vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php42
2 files changed, 95 insertions, 0 deletions
diff --git a/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php b/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php
new file mode 100644
index 000000000..25d1c3504
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Helpers/BitBufferTest.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Class BitBufferTest
+ *
+ * @filesource BitBufferTest.php
+ * @created 08.02.2016
+ * @package chillerlan\QRCodeTest\Helpers
+ * @author Smiley <[email protected]>
+ * @copyright 2015 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Helpers;
+
+use chillerlan\QRCode\{QRCode, Helpers\BitBuffer};
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+class BitBufferTest extends QRTestAbstract{
+
+ /**
+ * @var \chillerlan\QRCode\Helpers\BitBuffer
+ */
+ protected $bitBuffer;
+
+ protected function setUp():void{
+ $this->bitBuffer = new BitBuffer;
+ }
+
+ public function bitProvider(){
+ return [
+ 'number' => [QRCode::DATA_NUMBER, 16],
+ 'alphanum' => [QRCode::DATA_ALPHANUM, 32],
+ 'byte' => [QRCode::DATA_BYTE, 64],
+ 'kanji' => [QRCode::DATA_KANJI, 128],
+ ];
+ }
+
+ /**
+ * @dataProvider bitProvider
+ */
+ public function testPut($data, $value){
+ $this->bitBuffer->put($data, 4);
+ $this->assertSame($value, $this->bitBuffer->buffer[0]);
+ $this->assertSame(4, $this->bitBuffer->length);
+ }
+
+ public function testClear(){
+ $this->bitBuffer->clear();
+ $this->assertSame([], $this->bitBuffer->buffer);
+ $this->assertSame(0, $this->bitBuffer->length);
+ }
+
+}
diff --git a/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php b/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php
new file mode 100644
index 000000000..7f6da303c
--- /dev/null
+++ b/vendor/chillerlan/php-qrcode/tests/Helpers/PolynomialTest.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Class PolynomialTest
+ *
+ * @filesource PolynomialTest.php
+ * @created 09.02.2016
+ * @package chillerlan\QRCodeTest\Helpers
+ * @author Smiley <[email protected]>
+ * @copyright 2015 Smiley
+ * @license MIT
+ */
+
+namespace chillerlan\QRCodeTest\Helpers;
+
+use chillerlan\QRCode\Helpers\Polynomial;
+use chillerlan\QRCode\QRCodeException;
+use chillerlan\QRCodeTest\QRTestAbstract;
+
+class PolynomialTest extends QRTestAbstract{
+
+ /**
+ * @var \chillerlan\QRCode\Helpers\Polynomial
+ */
+ protected $polynomial;
+
+ protected function setUp():void{
+ $this->polynomial = new Polynomial;
+ }
+
+ public function testGexp(){
+ $this->assertSame(142, $this->polynomial->gexp(-1));
+ $this->assertSame(133, $this->polynomial->gexp(128));
+ $this->assertSame(2, $this->polynomial->gexp(256));
+ }
+
+ public function testGlogException(){
+ $this->expectException(QRCodeException::class);
+ $this->expectExceptionMessage('log(0)');
+
+ $this->polynomial->glog(0);
+ }
+}