From 87618d4b71250326840476937debf3e65ffba407 Mon Sep 17 00:00:00 2001 From: Brad Mostert Date: Fri, 30 Oct 2015 23:33:43 +0200 Subject: [PATCH] added tests for BinarySuffix with precision --- spec/Coduo/PHPHumanizer/NumberSpec.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spec/Coduo/PHPHumanizer/NumberSpec.php b/spec/Coduo/PHPHumanizer/NumberSpec.php index 6acaa24..8651a66 100644 --- a/spec/Coduo/PHPHumanizer/NumberSpec.php +++ b/spec/Coduo/PHPHumanizer/NumberSpec.php @@ -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");