summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorZachary Alex Stern <zacharyalexstern@gmail.com>2014-10-28 13:14:06 -0700
committerZachary Alex Stern <zacharyalexstern@gmail.com>2014-10-28 13:14:06 -0700
commit9295d0d5cae91f8c9b3b4b4fd891661666ab9e13 (patch)
treeb7119b529fb81d4951c949270734cf025b66b732 /spec
parent0cd08b377b58927aefa15908689a69dfb99339d5 (diff)
Added correct converstions for PB and EB.
* We were converting Exabytes to bytes as Petabytes. * Updated tests to cover ever unit. * Added note that we're going by the old, inaccurate definitions of Kilobytes, Megabytes, etc, in that we treat them as powers of 2.
Diffstat (limited to 'spec')
-rwxr-xr-xspec/functions/to_bytes_spec.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/functions/to_bytes_spec.rb b/spec/functions/to_bytes_spec.rb
index 68a1eb8..0f6ade9 100755
--- a/spec/functions/to_bytes_spec.rb
+++ b/spec/functions/to_bytes_spec.rb
@@ -18,6 +18,31 @@ describe "the to_bytes function" do
expect(result).to(eq(4096))
end
+ it "should convert MB to B" do
+ result = scope.function_to_bytes(["4 MB"])
+ expect(result).to(eq(4194304))
+ end
+
+ it "should convert GB to B" do
+ result = scope.function_to_bytes(["4 GB"])
+ expect(result).to(eq(4294967296))
+ end
+
+ it "should convert TB to B" do
+ result = scope.function_to_bytes(["4 TB"])
+ expect(result).to(eq(4398046511104))
+ end
+
+ it "should convert PB to B" do
+ result = scope.function_to_bytes(["4 PB"])
+ expect(result).to(eq(4503599627370496))
+ end
+
+ it "should convert PB to B" do
+ result = scope.function_to_bytes(["4 EB"])
+ expect(result).to(eq(4611686018427387904))
+ end
+
it "should work without B in unit" do
result = scope.function_to_bytes(["4 k"])
expect(result).to(eq(4096))