Skip to content

Commit

Permalink
added tests for BinarySuffix with precision
Browse files Browse the repository at this point in the history
  • Loading branch information
mostertb committed Oct 30, 2015
1 parent b0d1d53 commit 87618d4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions spec/Coduo/PHPHumanizer/NumberSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,20 @@ function it_convert_number_to_string_with_binary_suffix()
$this->binarySuffix(1325899906842624)->shouldReturn("1.18 PB");
}

function it_convert_number_to_string_with_binary_suffix_with_precision()
{
$this->binarySuffix(-1, 'en', 3)->shouldReturn(-1);
$this->binarySuffix(0, 'en', 3)->shouldReturn("0 bytes");
$this->binarySuffix(1, 'en', 3)->shouldReturn("1 bytes");
$this->binarySuffix(1024, 'en', 3)->shouldReturn("1.000 kB");
$this->binarySuffix(1025, 'en', 3)->shouldReturn("1.001 kB");
$this->binarySuffix(1536, 'en', 3)->shouldReturn("1.500 kB");
$this->binarySuffix(1048576 * 5, 'en', 3)->shouldReturn("5.000 MB");
$this->binarySuffix(1073741824 * 2, 'en', 3)->shouldReturn("2.000 GB");
$this->binarySuffix(1099511627776 * 3, 'en', 3)->shouldReturn("3.000 TB");
$this->binarySuffix(1325899906842624, 'en', 3)->shouldReturn("1.178 PB");
}

function it_convert_number_to_string_with_binary_suffix_for_specific_locale()
{
$this->binarySuffix(1536, 'pl')->shouldReturn("1,5 kB");
Expand Down

0 comments on commit 87618d4

Please sign in to comment.