summaryrefslogtreecommitdiff
path: root/vendor/christian-riesen/base32/tests/Base32Test.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
committerFrederic Guillot <fred@kanboard.net>2017-10-25 16:22:10 -0700
commit9e2b2a32fd0e967ad3184e9a5d091a29953acb91 (patch)
tree00822e24aa1110c73ca455a8d096ef296c008cbc /vendor/christian-riesen/base32/tests/Base32Test.php
parentc507c5416251c505cb3e088a03c6664bed73c812 (diff)
Include composer dependencies in repo
Diffstat (limited to 'vendor/christian-riesen/base32/tests/Base32Test.php')
-rw-r--r--vendor/christian-riesen/base32/tests/Base32Test.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/vendor/christian-riesen/base32/tests/Base32Test.php b/vendor/christian-riesen/base32/tests/Base32Test.php
new file mode 100644
index 00000000..3e5924ce
--- /dev/null
+++ b/vendor/christian-riesen/base32/tests/Base32Test.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Base32;
+
+use Base32\Base32;
+
+/**
+ * Base32 test case.
+ */
+class Base32Test extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * Tests Base32->decode()
+ *
+ * Testing test vectors according to RFC 4648
+ * http://www.ietf.org/rfc/rfc4648.txt
+ */
+ public function testDecode()
+ {
+ // RFC test vectors say that empty string returns empty string
+ $this->assertEquals('', Base32::decode(''));
+
+ // these strings are taken from the RFC
+ $this->assertEquals('f', Base32::decode('MY======'));
+ $this->assertEquals('fo', Base32::decode('MZXQ===='));
+ $this->assertEquals('foo', Base32::decode('MZXW6==='));
+ $this->assertEquals('foob', Base32::decode('MZXW6YQ='));
+ $this->assertEquals('fooba', Base32::decode('MZXW6YTB'));
+ $this->assertEquals('foobar', Base32::decode('MZXW6YTBOI======'));
+
+ // Decoding a string made up entirely of invalid characters
+ $this->assertEquals('', Base32::decode('8908908908908908'));
+ }
+
+ /**
+ * Encoder tests, reverse of the decodes
+ */
+ public function testEncode()
+ {
+ // RFC test vectors say that empty string returns empty string
+ $this->assertEquals('', Base32::encode(''));
+
+ // these strings are taken from the RFC
+ $this->assertEquals('MY======', Base32::encode('f'));
+ $this->assertEquals('MZXQ====', Base32::encode('fo'));
+ $this->assertEquals('MZXW6===', Base32::encode('foo'));
+ $this->assertEquals('MZXW6YQ=', Base32::encode('foob'));
+ $this->assertEquals('MZXW6YTB', Base32::encode('fooba'));
+ $this->assertEquals('MZXW6YTBOI======', Base32::encode('foobar'));
+ }
+}