Page Menu
Home
GnuPG
Search
Configure Global Search
Log In
Files
F36276333
PhabricatorUnitsTestCase.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Size
1 KB
Subscribers
None
PhabricatorUnitsTestCase.php
View Options
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final
class
PhabricatorUnitsTestCase
extends
PhabricatorTestCase
{
// NOTE: Keep tests below PHP_INT_MAX on 32-bit systems, since if you write
// larger numeric literals they'll evaluate to nonsense.
public
function
testByteFormatting
()
{
$tests
=
array
(
1
=>
'1 B'
,
1000
=>
'1 KB'
,
1000000
=>
'1 MB'
,
10000000
=>
'10 MB'
,
100000000
=>
'100 MB'
,
1000000000
=>
'1 GB'
,
999
=>
'999 B'
,
);
foreach
(
$tests
as
$input
=>
$expect
)
{
$this
->
assertEqual
(
$expect
,
phabricator_format_bytes
(
$input
),
'phabricator_format_bytes('
.
$input
.
')'
);
}
}
public
function
testByteParsing
()
{
$tests
=
array
(
'1'
=>
1
,
'1k'
=>
1000
,
'1K'
=>
1000
,
'1kB'
=>
1000
,
'1Kb'
=>
1000
,
'1KB'
=>
1000
,
'1MB'
=>
1000000
,
'1GB'
=>
1000000000
,
'1.5M'
=>
1500000
,
'1 000'
=>
1000
,
'1,234.56 KB'
=>
1234560
,
);
foreach
(
$tests
as
$input
=>
$expect
)
{
$this
->
assertEqual
(
$expect
,
phabricator_parse_bytes
(
$input
),
'phabricator_parse_bytes('
.
$input
.
')'
);
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Feb 22, 6:42 PM (1 d, 17 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
36/0d/d855f0b0bb0045b2f651d38a5ace
Attached To
rPHAB Phabricator
Event Timeline
Log In to Comment