spec/io_spec.rb in nmatrix-0.1.0.rc3 vs spec/io_spec.rb in nmatrix-0.1.0.rc4
- old
+ new
@@ -23,24 +23,17 @@
# == io_spec.rb
#
# Basic tests for NMatrix::IO.
#
require "tmpdir" # Used to avoid cluttering the repository.
-
+require 'spec_helper'
require "./lib/nmatrix"
describe NMatrix::IO do
- before :each do
- @tmp_dir = Dir.mktmpdir
- @test_out = File.join(@tmp_dir, "test-out")
- end
+ let(:tmp_dir) { Dir.mktmpdir }
+ let(:test_out) { File.join(tmp_dir, 'test-out') }
- after :each do
- File.delete(@test_out) if File.file?(@test_out)
- Dir.rmdir(@tmp_dir)
- end
-
it "repacks a string" do
expect(NMatrix::IO::Matlab.repack("hello", :miUINT8, :byte)).to eq("hello")
end
it "creates yale from internal byte-string function" do
@@ -100,57 +93,57 @@
expect{ NMatrix.read(fn) }.to raise_error(Errno::ENOENT)
end
it "reads and writes NMatrix dense" do
n = NMatrix.new(:dense, [4,3], [0,1,2,3,4,5,6,7,8,9,10,11], :int32)
- n.write(@test_out)
+ n.write(test_out)
- m = NMatrix.read(@test_out)
+ m = NMatrix.read(test_out)
expect(n).to eq(m)
end
it "reads and writes NMatrix dense as symmetric" do
n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :int16)
- n.write(@test_out, :symmetric)
+ n.write(test_out, :symmetric)
- m = NMatrix.read(@test_out)
+ m = NMatrix.read(test_out)
expect(n).to eq(m)
end
it "reads and writes NMatrix dense as skew" do
n = NMatrix.new(:dense, 3, [0,1,2,-1,3,4,-2,-4,5], :float64)
- n.write(@test_out, :skew)
+ n.write(test_out, :skew)
- m = NMatrix.read(@test_out)
+ m = NMatrix.read(test_out)
expect(n).to eq(m)
end
it "reads and writes NMatrix dense as hermitian" do
n = NMatrix.new(:dense, 3, [0,1,2,1,3,4,2,4,5], :complex64)
- n.write(@test_out, :hermitian)
+ n.write(test_out, :hermitian)
- m = NMatrix.read(@test_out)
+ m = NMatrix.read(test_out)
expect(n).to eq(m)
end
it "reads and writes NMatrix dense as upper" do
n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
- n.write(@test_out, :upper)
+ n.write(test_out, :upper)
m = NMatrix.new(:dense, 3, [-1,1,2,0,4,5,0,0,8], :int32) # lower version of the same
- o = NMatrix.read(@test_out)
+ o = NMatrix.read(test_out)
expect(o).to eq(m)
expect(o).not_to eq(n)
end
it "reads and writes NMatrix dense as lower" do
n = NMatrix.new(:dense, 3, [-1,1,2,3,4,5,6,7,8], :int32)
- n.write(@test_out, :lower)
+ n.write(test_out, :lower)
m = NMatrix.new(:dense, 3, [-1,0,0,3,4,0,6,7,8], :int32) # lower version of the same
- o = NMatrix.read(@test_out)
+ o = NMatrix.read(test_out)
expect(o).to eq(m)
expect(o).not_to eq(n)
end
end