module RubyUnit::Assertions::Comparisons
Public Instance Methods
Assert that two values are equal.
-
raises
RubyUnit::AssertionFailure
unless expected equals actual
- 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
Assert that one value is greater than another.
-
raises
RubyUnit::AssertionFailure
unless greater is greater than value
- 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
Assert that one value is greater than another.
-
raises
RubyUnit::AssertionFailure
unless greater is greater than or equal to value
- 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
Assert that one value is less than another.
-
raises
RubyUnit::AssertionFailure
unless less is less than value
- 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
Assert that one value is less than another.
-
raises
RubyUnit::AssertionFailure
unless less is less than or equal to value
- 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
Assert that a value matches a Regexp pattern.
-
raises
RubyUnit::AssertionFailure
unless value matches 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
Assert that two values are NOT equal.
-
raises
RubyUnit::AssertionFailure
if illegal equals actual
- 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
Assert that a value does not match a Regexp pattern.
-
raises
RubyUnit::AssertionFailure
if value matches 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
Assert that two objects are not the same object
-
raises
RubyUnit::AssertionFailure
if illegal and actual are 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
Assert that two objects are the same object
-
raises
RubyUnit::AssertionFailure
unless expected and actual 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