module RubyUnit::Assertions::Comparisons

Public Instance Methods

assertEqual(expected, actual, message = nil) click to toggle source

Assert that two values are equal.

expected

The value that is forbidden by the assertion

actual

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertEqual 42, 24, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 24
def assertEqual expected, actual, message = nil
  __assert (expected == actual), ASSERT_EQUAL_ERROR, message, {:expected=>expected, :actual=>actual}
end
assertGreaterThan(greater, value, message = nil) click to toggle source

Assert that one value is greater than another.

greater

The value that should be greater

value

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertGreaterThan 24, 42, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 62
def assertGreaterThan greater, value, message = nil
  __assert (greater > value), ASSERT_GREATERTHAN_ERROR, message, {:greater=>greater, :value=>value}
end
assertGreaterThanOrEqual(greater, value, message = nil) click to toggle source

Assert that one value is greater than another.

greater

The value that should be greater than or equal

value

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertGreaterThanOrEqual 24, 42, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 81
def assertGreaterThanOrEqual greater, value, message = nil
  __assert (greater >= value), ASSERT_GREATERTHANOREQUAL_ERROR, message, {:greater=>greater, :value=>value}
end
assertLessThan(less, value, message = nil) click to toggle source

Assert that one value is less than another.

less

The value that should be less

value

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertLessThan 42, 24, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 100
def assertLessThan less, value, message = nil
  __assert (less < value), ASSERT_LESSTHAN_ERROR, message, {:less=>less, :value=>value}
end
assertLessThanOrEqual(less, value, message = nil) click to toggle source

Assert that one value is less than another.

less

The value that should be less than or equal

value

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertLessThanOrEqual 42, 24, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 119
def assertLessThanOrEqual less, value, message = nil
  __assert (less <= value), ASSERT_LESSTHANOREQUAL_ERROR, message, {:less=>less, :value=>value}
end
assertMatch(pattern, value, message = nil) click to toggle source

Assert that a value matches a Regexp pattern.

pattern

A Regexp pattern expected by the assertion

value

The value that is being checked for the assertion

message

The message provided to be reported for a failure

assertMatch /^Hello/, 'Goodbye!', "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 138
def assertMatch pattern, value, message = nil
  pattern = [pattern] unless pattern.is_a? Array
  pattern.each do |regex|
    __assert (value =~ regex), ASSERT_MATCH_ERROR, message, {:pattern=>pattern, :value=>value}
  end
end
assertNotEqual(illegal, actual, message = nil) click to toggle source

Assert that two values are NOT equal.

illegal

The value that is not allowed by the assertion

actual

The value that is being checked by the assertion

message

The message provided to be reported for a failure

assertNotEqual 3.14, 3.14, "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 43
def assertNotEqual illegal, actual, message = nil
  __reject (illegal == actual), ASSERT_NOT_EQUAL_ERROR, message, {:illegal=>illegal, :actual=>actual} 
end
assertNotMatch(exclusion, value, message = nil) click to toggle source

Assert that a value does not match a Regexp pattern.

pattern

A Regexp pattern excluded by the assertion

value

The value that is being checked for the assertion

message

The message provided to be reported for a failure

assertMatch /^Good/, 'Goodbye!', "This will fail"  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 160
def assertNotMatch exclusion, value, message = nil
  __reject (value =~ exclusion), ASSERT_NOT_MATCH_ERROR, message, {:exclusion=>exclusion, :value=>value}
end
assertNotSame(illegal, actual, message = nil) click to toggle source

Assert that two objects are not the same object

illegal

The expected that it shouldn’t be

actual

The object that is being checked against illegal

message

The message provided to be reported for a failure

assertNotSame value, value, 'Imagine that!'  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 200
def assertNotSame illegal, actual, message = nil
  __reject (illegal.equal? actual), ASSERT_NOT_SAME_ERROR, message, {:illegal=>illegal, :actual=>actual}
end
assertSame(expected, actual, message = nil) click to toggle source

Assert that two objects are the same object

expected

The expected object

actual

The object that is being checked against expected

message

The message provided to be reported for a failure

assertSame '42', 42, 'Not even close.'  # => fail
# File lib/RubyUnit/Assertions/Comparisons.rb, line 180
def assertSame expected, actual, message = nil
  __assert (expected.equal? actual), ASSERT_SAME_ERROR, message, {:expected=>expected, :actual=>actual}
end