Sha256: 4bf937c002a6448fce0fcc1ea21b369e28f87c05b446d98680e161a745f49cb2

Contents?: true

Size: 1.55 KB

Versions: 106

Compression:

Stored size: 1.55 KB

Contents

class TestUnitColor < Test::Unit::TestCase
  def test_color_escape_sequence
    assert_escape_sequence(["31"], color("red"))
    assert_escape_sequence(["32", "1"], color("green", :bold => true))
    assert_escape_sequence(["0"], color("reset"))
    assert_escape_sequence(["45"], color("magenta", :foreground => false))
  end

  def test_mix_color_escape_sequence
    assert_escape_sequence(["34", "1"],
                           mix_color([color("blue"),
                                      color("none", :bold => true)]))
    assert_escape_sequence(["34", "1", "4"],
                           mix_color([color("blue"),
                                      color("none", :bold => true)]) +
                           color("none", :underline => true))
    assert_escape_sequence(["34", "1", "4"],
                           color("blue") +
                           color("none", :bold => true) +
                           color("none", :underline => true))
  end

  def test_equal
    red = color("red")
    red_bold = color("red", :bold => true)

    assert_operator(red, :==, red)
    assert_not_equal(red, nil)
    assert_equal(red, color("red"))
    assert_not_equal(red, red_bold)
  end

  private
  def color(name, options={})
    Test::Unit::Color.new(name, options)
  end

  def mix_color(colors)
    Test::Unit::MixColor.new(colors)
  end

  def assert_escape_sequence(expected, color)
    assert_equal(expected, color.sequence)
    assert_match(/\e\[(?:\d+;)*\d+m/, color.escape_sequence)
    assert_equal(expected, color.escape_sequence[2..-2].split(";"))
  end
end

Version data entries

106 entries across 90 versions & 11 rubygems

Version Path
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/test-unit-2.4.8/test/test-color.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/test-unit-2.4.8/test/test-color.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/test-unit-2.5.0/test/test-color.rb
candlepin-api-0.4.0 bundle/ruby/gems/test-unit-2.5.0/test/test-color.rb
candlepin-api-0.4.0 bundle/ruby/1.9.1/gems/test-unit-2.5.0/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.3/vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.3 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/bitclust-core-0.5.1/vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.2 vendor/bundle/ruby/1.9.1/gems/test-unit-2.4.8/test/test-color.rb
bitclust-core-0.5.1 vendor/bundle/ruby/1.9.1/gems/test-unit-2.5.1/test/test-color.rb