diff options
author | Akshay Vishnoi <akshay.vishnoi@vinsol.com> | 2015-12-22 23:05:50 +0530 |
---|---|---|
committer | Akshay Vishnoi <akshay.vishnoi@vinsol.com> | 2015-12-22 23:07:06 +0530 |
commit | 3d1f95d0e8ca70f5d892d9b2ed78e99ff7cb3bde (patch) | |
tree | 063fa8ff94f7cec601b58c8b4a52e6657c95c3f6 /activesupport/test/core_ext/numeric_ext_test.rb | |
parent | 47fd7c95555cb1c6e05768cd1b9ee38ad5cf9d1f (diff) | |
download | rails-3d1f95d0e8ca70f5d892d9b2ed78e99ff7cb3bde.tar.gz rails-3d1f95d0e8ca70f5d892d9b2ed78e99ff7cb3bde.tar.bz2 rails-3d1f95d0e8ca70f5d892d9b2ed78e99ff7cb3bde.zip |
Add support for Petabyte and Exabyte in number to human size
Diffstat (limited to 'activesupport/test/core_ext/numeric_ext_test.rb')
-rw-r--r-- | activesupport/test/core_ext/numeric_ext_test.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/activesupport/test/core_ext/numeric_ext_test.rb b/activesupport/test/core_ext/numeric_ext_test.rb index 0ff8f0f89b..8636da1b93 100644 --- a/activesupport/test/core_ext/numeric_ext_test.rb +++ b/activesupport/test/core_ext/numeric_ext_test.rb @@ -143,6 +143,14 @@ class NumericExtFormattingTest < ActiveSupport::TestCase gigabytes(number) * 1024 end + def petabytes(number) + terabytes(number) * 1024 + end + + def exabytes(number) + petabytes(number) * 1024 + end + def test_to_s__phone assert_equal("555-1234", 5551234.to_s(:phone)) assert_equal("800-555-1212", 8005551212.to_s(:phone)) @@ -266,7 +274,9 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal '1.18 MB', 1234567.to_s(:human_size) assert_equal '1.15 GB', 1234567890.to_s(:human_size) assert_equal '1.12 TB', 1234567890123.to_s(:human_size) - assert_equal '1030 TB', terabytes(1026).to_s(:human_size) + assert_equal '1.1 PB', 1234567890123456.to_s(:human_size) + assert_equal '1.07 EB', 1234567890123456789.to_s(:human_size) + assert_equal '1030 EB', exabytes(1026).to_s(:human_size) assert_equal '444 KB', kilobytes(444).to_s(:human_size) assert_equal '1020 MB', megabytes(1023).to_s(:human_size) assert_equal '3 TB', terabytes(3).to_s(:human_size) @@ -289,6 +299,8 @@ class NumericExtFormattingTest < ActiveSupport::TestCase assert_equal '1.23 MB', 1234567.to_s(:human_size, :prefix => :si) assert_equal '1.23 GB', 1234567890.to_s(:human_size, :prefix => :si) assert_equal '1.23 TB', 1234567890123.to_s(:human_size, :prefix => :si) + assert_equal '1.23 PB', 1234567890123456.to_s(:human_size, :prefix => :si) + assert_equal '1.23 EB', 1234567890123456789.to_s(:human_size, :prefix => :si) end end |