|
@ -2,13 +2,6 @@ require_relative '../../lib/formatters/wrapper' |
|
|
require 'test/unit' |
|
|
require 'test/unit' |
|
|
|
|
|
|
|
|
class TestWrapper < Test::Unit::TestCase |
|
|
class TestWrapper < Test::Unit::TestCase |
|
|
SCORE_ANSI = "début\e[0;35m\e[0;36mMarron\e[0mMoyen\e[0;35mBleu\e[0mFin\e[0;35m" |
|
|
|
|
|
SCORE_ANSI2 = "\e[0;35mMauve\e[0m" |
|
|
|
|
|
SQL_ANSI = "\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mSELECT \"scores\".* FROM \"scores\" WHERE \"scores\".\"id\" = $1 LIMIT $2\e[0m [[\"id\", 2], [\"LIMIT\", 1]]" |
|
|
|
|
|
|
|
|
|
|
|
BEGINT = "my text is:\n" |
|
|
|
|
|
ENDOFT = "a final is:\n" |
|
|
|
|
|
|
|
|
|
|
|
def test_wrap_score |
|
|
def test_wrap_score |
|
|
assert_wrap("\ |
|
|
assert_wrap("\ |
|
|
********************\n\ |
|
|
********************\n\ |
|
@ -31,20 +24,22 @@ class TestWrapper < Test::Unit::TestCase |
|
|
\e[0;36mores\".\"id\" = $1 LIMI\e[0m\n\ |
|
|
\e[0;36mores\".\"id\" = $1 LIMI\e[0m\n\ |
|
|
\e[0;36mT $2\e[0m [[\"id\", 2], [\"L\n\ |
|
|
\e[0;36mT $2\e[0m [[\"id\", 2], [\"L\n\ |
|
|
IMIT\", 1]]", "\ |
|
|
IMIT\", 1]]", "\ |
|
|
\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mSELECT \"scores\".* FROM \"scores\" WHERE \"scores\".\"id\" = $1 LIMIT $2\e[0m [[\"id\", 2], [\"LIMIT\", 1]]", |
|
|
|
|
|
20) |
|
|
|
|
|
|
|
|
\e[0;35mScore Load (0.6ms)\e[0m \e[0;36mSELECT \"scores\".* FROM \"scores\" WHERE \"scores\".\"id\" = $1 LIMIT $2\e[0m [[\"id\", 2], [\"LIMIT\", 1]]", |
|
|
|
|
|
20) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
private |
|
|
private |
|
|
|
|
|
|
|
|
def assert_wrap(expectation, text, length, prefix = '') |
|
|
def assert_wrap(expectation, text, length, prefix = '') |
|
|
assert_equal(expectation, prefix+Wrapper.wrap(text, prefix, length - prefix.length)) |
|
|
|
|
|
|
|
|
assert_equal(expectation, prefix + Wrapper.wrap(text, prefix, length - prefix.length)) |
|
|
test_with_style(text, length, prefix) |
|
|
test_with_style(text, length, prefix) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
def test_with_style(text, length, prefix = '') |
|
|
def test_with_style(text, length, prefix = '') |
|
|
puts "#{BEGINT}#{prefix}#{text}\e[0m" |
|
|
|
|
|
puts "#{ENDOFT}#{prefix}#{Wrapper.wrap(text, prefix, length - prefix.length)}\e[0m" |
|
|
|
|
|
|
|
|
begint = "my text is:\n" |
|
|
|
|
|
endoft = "a final is:\n" |
|
|
|
|
|
puts "#{begint}#{prefix}#{text}\e[0m" |
|
|
|
|
|
puts "#{endoft}#{prefix}#{Wrapper.wrap(text, prefix, length - prefix.length)}\e[0m" |
|
|
puts |
|
|
puts |
|
|
end |
|
|
end |
|
|
end |
|
|
end |