Rework store_test.rb using rspec
[quanlib.git] / test / store_test.rb
diff --git a/test/store_test.rb b/test/store_test.rb
new file mode 100644 (file)
index 0000000..5ebeff1
--- /dev/null
@@ -0,0 +1,24 @@
+
+require 'rspec/autorun'
+require_relative '../store'
+
+describe Store do
+  it "construct_efs_path produces paths and filenames as expected" do
+    data = [
+      [      1234, '00/00/00/12', '0000001234.dat'],
+      [         1, '00/00/00/00', '0000000001.dat'],
+      [1234567890, '12/34/56/78', '1234567890.dat'],
+      [   7778123, '00/07/77/81', '0007778123.dat'],
+      [      0x1b, '00/00/00/00', '0000000027.dat']
+    ]
+
+    store = Store.new('quanlib.ini')
+
+    data.each do |input, expectedPath, expectedName|
+      (actualPath, actualName) = store.construct_efs_path(input)
+
+      expect(actualPath).to eq(expectedPath)
+      expect(actualName).to eq(expectedName)
+    end
+  end
+end