1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-30 21:40:43 +02:00

Merge PR #1074 branch 'bantu/ticket/11192' into develop-olympus

* bantu/ticket/11192:
  [ticket/11192] Merge dataProvider arrays because the test is the same now.
  [ticket/11192] Update $value parameter description to support other types.
  [ticket/11192] Mark negative byte numbers as unsupported.
  [ticket/11192] Test strings not converted to int/float before.
  [ticket/11192] Also test strings, e.g. sums returned by the database.
  [ticket/11192] Also test powers of 10 / 1000.
  [ticket/11192] Add tests.
  [ticket/11192] Add Tebibyte to get_formatted_filesize().
This commit is contained in:
Oleg Pudeyev
2012-11-16 10:25:06 -05:00
3 changed files with 81 additions and 1 deletions

View File

@@ -0,0 +1,71 @@
<?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'),
// exact powers of 10
array(1000, '1000 BYTES'),
array(1000000, '976.56 KIB'),
array(1000000000, '953.67 MIB'),
array(1000000000000, '931.32 GIB'),
array(100000000000000, '90.95 TIB'),
array(0, '0 BYTES'),
array(2, '2 BYTES'),
array(1023, '1023 BYTES'),
array(1025, '1 KIB'),
array(1048575, '1024 KIB'),
// String values
// exact powers of 2
array('1', '1 BYTES'),
array('1024', '1 KIB'),
array('1048576', '1 MIB'),
array('1073741824', '1 GIB'),
array('1099511627776', '1 TIB'),
// exact powers of 10
array('1000', '1000 BYTES'),
array('1000000', '976.56 KIB'),
array('1000000000', '953.67 MIB'),
array('1000000000000', '931.32 GIB'),
array('100000000000000', '90.95 TIB'),
array('0', '0 BYTES'),
array('2', '2 BYTES'),
array('1023', '1023 BYTES'),
array('1025', '1 KIB'),
array('1048575', '1024 KIB'),
);
}
/**
* @dataProvider get_formatted_filesize_test_data
*/
public function test_get_formatted_filesize($input, $expected)
{
$output = get_formatted_filesize($input);
$this->assertEquals($expected, $output);
}
}