Sha256: f1096930fffcb60cf0cdf387cdb85e00076e61cf4d0add1e2550efbe006b888b

Contents?: true

Size: 1.77 KB

Versions: 24

Compression:

Stored size: 1.77 KB

Contents

require 'test/unit'

require 'rd/version'

include RD

class TestVersion < Test::Unit::TestCase
  def test_s_new_from_version_string
    ver011 = Version.new_from_version_string("name", "$Version: 0.1.1$") # "
    assert_equal("name", ver011.name)
    assert_equal(0, ver011.major)
    assert_equal(1, ver011.minor)
    assert_equal(1, ver011.patch_level)

    ver0101 = Version.new_from_version_string("name", "$Version: 0.10.1$") #"
    assert_equal(0, ver0101.major)
    assert_equal(10, ver0101.minor)
    assert_equal(1, ver0101.patch_level)

    ver01 = Version.new_from_version_string("name", "$Version: 0.1$") # "
    assert_equal(0, ver01.major)
    assert_equal(1, ver01.minor)
    assert_equal(nil, ver01.patch_level)

    ver0 = Version.new_from_version_string("name", "$Version: 0$") # "
    assert_equal(0, ver0.major)
    assert_equal(nil, ver0.minor)
    assert_equal(nil, ver0.patch_level)
    
    ver011_2 = Version.new_from_version_string("name", "0.1.1") # "
    assert_equal("name", ver011_2.name)
    assert_equal(0, ver011_2.major)
    assert_equal(1, ver011_2.minor)
    assert_equal(1, ver011_2.patch_level)
  end

  def test_s_clean_up_version_string
    assert_equal("0.1.1",
                 Version.clean_up_version_string("$Version: 0.1.1$")) #"
    assert_equal("0.1.1",
                 Version.clean_up_version_string("0.1.1"))
    assert_equal("", Version.clean_up_version_string("$Version$")) # "
  end

  def test_to_s
    ver011 = Version.new("name", 0, 1, 1)
    assert_equal("name 0.1.1", ver011.to_s)
    ver0101 = Version.new("name", 0, 10, 1)
    assert_equal("name 0.10.1", ver0101.to_s)

    ver01 = Version.new("name", 0, 1, nil)
    assert_equal("name 0.1", ver01.to_s)

    ver0 = Version.new("name", 0, nil, nil)
    assert_equal("name 0", ver0.to_s)
  end
end

Version data entries

24 entries across 23 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/rdtool-0.6.38/test/test-version.rb
tdiary-5.0.8 vendor/bundle/gems/rdtool-0.6.38/test/test-version.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/rdtool-0.6.38/test/test-version.rb
tdiary-5.0.5 vendor/bundle/gems/rdtool-0.6.38/test/test-version.rb
tdiary-5.0.4 vendor/bundle/gems/rdtool-0.6.38/test/test-version.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/rdtool-0.6.38/test/test-version.rb
tdiary-3.2.2.20130518 vendor/rdtool-0.6.38/test/test-version.rb
tdiary-3.2.2.20130508 vendor/rdtool-0.6.38/test/test-version.rb
tdiary-3.2.2.20130507 vendor/rdtool-0.6.38/test/test-version.rb
rdtool-0.6.38 test/test-version.rb
rdtool-0.6.37 test/test-version.rb
rdtool-0.6.36 test/test-version.rb
rdtool-0.6.35 test/test-version.rb
rdtool-0.6.34 test/test-version.rb
rdtool-0.6.33 test/test-version.rb
rdtool-0.6.32 test/test-version.rb
rdtool-0.6.31 test/test-version.rb
rdtool-0.6.30 test/test-version.rb
rdtool-0.6.29 test/test-version.rb
rdtool-0.6.28 test/test-version.rb