function CommonSizeTestCase::testCommonParseSize
Check that parse_size() returns the proper byte sizes.
Archivo
- drupal-7.x/
modules/ simpletest/ tests/ common.test, line 483 - Tests for common.inc functionality.
Class
- CommonSizeTestCase
- Tests file size parsing and formatting functions.
Código
function testCommonParseSize() {
foreach ($this->exact_test_cases as $string => $size) {
$this->assertEqual($parsed_size = parse_size($string), $size, $size . ' == ' . $parsed_size . ' (' . $string . ')');
}
// Some custom parsing tests
$string = '23476892 bytes';
$this->assertEqual(($parsed_size = parse_size($string)), $size = 23476892, $string . ' == ' . $parsed_size . ' bytes');
$string = '76MRandomStringThatShouldBeIgnoredByParseSize.'; // 76 MB
$this->assertEqual($parsed_size = parse_size($string), $size = 79691776, $string . ' == ' . $parsed_size . ' bytes');
$string = '76.24 Giggabyte'; // Misspeld text -> 76.24 GB
$this->assertEqual($parsed_size = parse_size($string), $size = 81862076662, $string . ' == ' . $parsed_size . ' bytes');
}