Sha256: b969123dae916e6ff1ce37922c06cf4d357e9c8b2229dbb2f370cd38b5556328
Contents?: true
Size: 1.64 KB
Versions: 1
Compression:
Stored size: 1.64 KB
Contents
gem 'minitest' require 'minitest/autorun' require 'color' module TestColor class TestYIQ < Minitest::Test def setup @yiq = Color::YIQ.from_fraction(0.1, 0.2, 0.3) end def test_brightness assert_in_delta(0.1, @yiq.brightness, Color::COLOR_TOLERANCE) end def test_i assert_in_delta(0.2, @yiq.i, Color::COLOR_TOLERANCE) assert_in_delta(0.2, @yiq.i, Color::COLOR_TOLERANCE) @yiq.i = 0.5 assert_in_delta(0.5, @yiq.i, Color::COLOR_TOLERANCE) @yiq.i = 5 assert_in_delta(1.0, @yiq.i, Color::COLOR_TOLERANCE) @yiq.i = -5 assert_in_delta(0.0, @yiq.i, Color::COLOR_TOLERANCE) end def test_q assert_in_delta(0.3, @yiq.q, Color::COLOR_TOLERANCE) assert_in_delta(0.3, @yiq.q, Color::COLOR_TOLERANCE) @yiq.q = 0.5 assert_in_delta(0.5, @yiq.q, Color::COLOR_TOLERANCE) @yiq.q = 5 assert_in_delta(1.0, @yiq.q, Color::COLOR_TOLERANCE) @yiq.q = -5 assert_in_delta(0.0, @yiq.q, Color::COLOR_TOLERANCE) end def test_to_grayscale assert_equal(Color::GrayScale.new(0.1), @yiq.to_grayscale) end def test_to_yiq assert_equal(@yiq, @yiq.to_yiq) end def test_y assert_in_delta(0.1, @yiq.y, Color::COLOR_TOLERANCE) assert_in_delta(0.1, @yiq.y, Color::COLOR_TOLERANCE) @yiq.y = 0.5 assert_in_delta(0.5, @yiq.y, Color::COLOR_TOLERANCE) @yiq.y = 5 assert_in_delta(1.0, @yiq.y, Color::COLOR_TOLERANCE) @yiq.y = -5 assert_in_delta(0.0, @yiq.y, Color::COLOR_TOLERANCE) end def test_inspect assert_equal("YIQ [10.00%, 20.00%, 30.00%]", @yiq.inspect) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
color-1.4.2 | test/test_yiq.rb |