aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Pudeyev <oleg@bsdpower.com>2012-11-15 23:57:55 -0500
committerOleg Pudeyev <oleg@bsdpower.com>2012-11-15 23:57:55 -0500
commitc15b98999ef1ba26531e3d6e20695a8f2672f5a4 (patch)
tree1a0bcd5355384cdad7b14330b32f77e3c683fa40
parentc699b88bc58ae07fffb33611a6d7ed950bbb1e15 (diff)
downloadforums-c15b98999ef1ba26531e3d6e20695a8f2672f5a4.tar
forums-c15b98999ef1ba26531e3d6e20695a8f2672f5a4.tar.gz
forums-c15b98999ef1ba26531e3d6e20695a8f2672f5a4.tar.bz2
forums-c15b98999ef1ba26531e3d6e20695a8f2672f5a4.tar.xz
forums-c15b98999ef1ba26531e3d6e20695a8f2672f5a4.zip
[ticket/11192] Add tests.
PHPBB3-11192
-rw-r--r--tests/functions/get_formatted_filesize_test.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/functions/get_formatted_filesize_test.php b/tests/functions/get_formatted_filesize_test.php
new file mode 100644
index 0000000000..1cc7ddf9ec
--- /dev/null
+++ b/tests/functions/get_formatted_filesize_test.php
@@ -0,0 +1,50 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_get_formatted_filesize_test extends phpbb_test_case
+{
+ public function get_formatted_filesize_test_data()
+ {
+ return array(
+ // exact powers of 2
+ array(1, '1 BYTES'),
+ array(1024, '1 KIB'),
+ array(1048576, '1 MIB'),
+ array(1073741824, '1 GIB'),
+ array(1099511627776, '1 TIB'),
+
+ array(0, '0 BYTES'),
+ array(2, '2 BYTES'),
+ array(-2, '-2 BYTES'),
+
+ array(1023, '1023 BYTES'),
+ array(1025, '1 KIB'),
+ array(-1023, '-1023 BYTES'),
+ array(-1025, '-1025 BYTES'),
+
+ array(1048575, '1024 KIB'),
+
+ // large negatives
+ array(-1073741824, '-1073741824 BYTES'),
+ array(-1099511627776, '-1099511627776 BYTES'),
+ );
+ }
+
+ /**
+ * @dataProvider get_formatted_filesize_test_data
+ */
+ public function test_get_formatted_filesize($input, $expected)
+ {
+ $output = get_formatted_filesize($input);
+
+ $this->assertEquals($expected, $output);
+ }
+}