test/driver/native/test_conversions.rb in octave-ruby-1.0.8 vs test/driver/native/test_conversions.rb in octave-ruby-1.0.9
- old
+ new
@@ -99,21 +99,22 @@
def test_should_convert_an_empty_ruby_array
assert_octave_and_ruby_equal []
end
- def test_should_convert_a_1xn_octave_matrix_to_an_array
+ def test_should_convert_a_1xn_octave_matrix_to_an_octave_matrix
matrix = Octave::Matrix.new(1, 3)
matrix[0, 0] = 1
matrix[0, 1] = 2
matrix[0, 2] = 3
- expected_array = [1,2,3]
- result = to_octave_to_ruby(matrix)
-
- assert_equal expected_array, result
- assert_instance_of Array, result
+ result = @driver.put_variable "octave_matrix", matrix
+
+ assert_instance_of Octave::Matrix, result
+ assert_equal matrix, result
+ assert_equal 1, @driver.feval("rows", result)
+ assert_equal 3, @driver.feval("columns", result)
end
def test_should_convert_an_nx1_octave_matrix_to_an_array
matrix = Octave::Matrix.new(3, 1)
matrix[0, 0] = 1
@@ -123,10 +124,12 @@
expected_array = [1,2,3]
result = to_octave_to_ruby(matrix)
assert_equal expected_array, result
assert_instance_of Array, result
+ assert_equal 3, @driver.feval("rows", result)
+ assert_equal 1, @driver.feval("columns", result)
end
def test_should_convert_octave_struct_matrix
struct_matrix = Octave::StructMatrix.new(17, 2, "name", "age", "married", "cats", "car")
17.times do |m|
@@ -167,16 +170,21 @@
cell_matrix[0,0] = [1, 2, 3]
assert_equal [1, 2, 3], to_octave_to_ruby(cell_matrix)
end
- def test_should_convert_a_1xn_cell_matrix_to_an_array
+ def test_should_convert_a_1xn_cell_matrix_to_an_octave_cell_matrix
cell_matrix = Octave::CellMatrix.new(1, 3)
cell_matrix[0,0] = "foo"
cell_matrix[0,1] = "bar"
cell_matrix[0,2] = "baz"
- assert_equal %w(foo bar baz), to_octave_to_ruby(cell_matrix)
+ result = @driver.put_variable "octave_cell_matrix", cell_matrix
+
+ assert_instance_of Octave::CellMatrix, result
+ assert_equal cell_matrix, result
+ assert_equal 1, @driver.feval("rows", result)
+ assert_equal 3, @driver.feval("columns", result)
end
def test_should_convert_a_nx1_cell_matrix_to_an_array
cell_matrix = Octave::CellMatrix.new(3, 1)
cell_matrix[0,0] = "foo"