module MiniTest::Assertions

Public Instance Methods

assert_equal_matrix(exp,obs,delta=1e-10,msg=nil) click to toggle source
# File pkg/statsample-1.4.0/test/helpers_tests.rb, line 48
def assert_equal_matrix(exp,obs,delta=1e-10,msg=nil)
   assert_equal(exp.row_size, obs.row_size, "Different row size.#{msg}")
   assert_equal(exp.column_size, obs.column_size, "Different column size.#{msg}")
   exp.row_size.times {|i|
     exp.column_size.times {|j|
       assert_in_delta(exp[i,j],obs[i,j], delta, "Different element #{i},#{j}\nExpected:\n#{exp}\nObserved:\n#{obs}.#{msg}")
     }
   }
end
assert_equal_vector(exp,obs,delta=1e-10,msg=nil) click to toggle source
# File pkg/statsample-1.4.0/test/helpers_tests.rb, line 42
def assert_equal_vector(exp,obs,delta=1e-10,msg=nil)
  assert_equal(exp.size, obs.size, "Different size.#{msg}")
  exp.size.times {|i|
    assert_in_delta(exp[i],obs[i],delta, "Different element #{i}. \nExpected:\n#{exp}\nObserved:\n#{obs}.#{msg}")
  }
end
assert_nothing_raised(msg=nil) { || ... } click to toggle source
# File pkg/statsample-1.4.0/test/helpers_tests.rb, line 61
def assert_nothing_raised(msg=nil)
  msg||="Nothing should be raised, but raised %s"
  begin
    yield
    not_raised=true
  rescue Exception => e
    not_raised=false
    msg=sprintf(msg,e)
  end
  assert(not_raised,msg)
end
assert_similar_vector(exp, obs, delta=1e-10,msg=nil) click to toggle source
# File pkg/statsample-1.4.0/test/helpers_tests.rb, line 35
def assert_similar_vector(exp, obs, delta=1e-10,msg=nil)
  msg||="Different vectors #{exp} - #{obs}"
  assert_equal(exp.size, obs.size)
  exp.data_with_nils.each_with_index {|v,i|
    assert_in_delta(v,obs[i],delta)
  }
end