Flesh out MacOSVersion tests

This commit is contained in:
Jack Nagel 2013-02-06 22:49:43 -06:00
parent 61c7a99cc8
commit b41bb64c7a
2 changed files with 41 additions and 14 deletions

View File

@ -0,0 +1,41 @@
require 'testing_env'
require 'version'
class MacOSVersionTests < Test::Unit::TestCase
def setup
@v = MacOSVersion.new(10.7)
end
def test_compare_with_symbol
assert_operator @v, :>, :snow_leopard
assert_operator @v, :==, :lion
assert_operator @v, :===, :lion
assert_operator @v, :<, :mountain_lion
end
def test_compare_with_fixnum
assert_operator @v, :>, 10
assert_operator @v, :<, 11
end
def test_compare_with_float
assert_operator @v, :>, 10.6
assert_operator @v, :==, 10.7
assert_operator @v, :===, 10.7
assert_operator @v, :<, 10.8
end
def test_compare_with_string
assert_operator @v, :>, "10.6"
assert_operator @v, :==, "10.7"
assert_operator @v, :===, "10.7"
assert_operator @v, :<, "10.8"
end
def test_compare_with_version
assert_operator @v, :>, Version.new(10.6)
assert_operator @v, :==, Version.new(10.7)
assert_operator @v, :===, Version.new(10.7)
assert_operator @v, :<, Version.new(10.8)
end
end

View File

@ -33,20 +33,6 @@ class VersionComparisonTests < Test::Unit::TestCase
assert_nil version('1.0') <=> 'foo' assert_nil version('1.0') <=> 'foo'
end end
def test_macos_version_comparison
v = MacOSVersion.new(10.6)
assert v == 10.6
assert v == :snow_leopard
assert v < :lion
# Test that we can compare against different representations
assert v <= 10.8
assert v < "10.8"
assert v < :mountain_lion
assert v < 11
assert v < Version.new(10.8)
assert Version.new(10.5) < v
end
def test_version_interrogation def test_version_interrogation
v = Version.new("1.1alpha1") v = Version.new("1.1alpha1")
assert v.alpha? assert v.alpha?