summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorAndreas Fischer <bantu@owncloud.com>2014-02-15 23:21:23 +0100
committerAndreas Fischer <bantu@owncloud.com>2014-05-29 16:26:01 +0200
commit2c36a4b07a088bca4f20c2f6386765dfc8ad07b7 (patch)
tree16f27fe03c0c6213c7aa5cbcb74c3deca8519cb6 /tests/lib
parent82e17155bf11161a4f86a4d23872ebee753d63e2 (diff)
downloadnextcloud-server-2c36a4b07a088bca4f20c2f6386765dfc8ad07b7.tar.gz
nextcloud-server-2c36a4b07a088bca4f20c2f6386765dfc8ad07b7.zip
Add helper method for turning int|float into base-10 unsigned integer string.
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/largefilehelper.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/lib/largefilehelper.php b/tests/lib/largefilehelper.php
new file mode 100644
index 00000000000..5db1f9c5a74
--- /dev/null
+++ b/tests/lib/largefilehelper.php
@@ -0,0 +1,46 @@
+<?php
+/**
+ * Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace Test;
+
+class LargeFileHelper extends \PHPUnit_Framework_TestCase {
+ protected $helper;
+
+ public function setUp() {
+ parent::setUp();
+ $this->helper = new \OC\LargeFileHelper;
+ }
+
+ public function testFormatUnsignedIntegerFloat() {
+ $this->assertSame(
+ '9007199254740992',
+ $this->helper->formatUnsignedInteger((float) 9007199254740992)
+ );
+ }
+
+ public function testFormatUnsignedIntegerInt() {
+ $this->assertSame(
+ PHP_INT_SIZE === 4 ? '4294967295' : '18446744073709551615',
+ $this->helper->formatUnsignedInteger(-1)
+ );
+ }
+
+ public function testFormatUnsignedIntegerString() {
+ $this->assertSame(
+ '9007199254740993',
+ $this->helper->formatUnsignedInteger('9007199254740993')
+ );
+ }
+
+ /**
+ * @expectedException \UnexpectedValueException
+ */
+ public function testFormatUnsignedIntegerStringException() {
+ $this->helper->formatUnsignedInteger('900ABCD254740993');
+ }
+}