require 'test/unit'
require 'linko'
Linko::WORDS.replace({
'Ruby' => 'http://www.ruby-lang.org/',
'foo' => 'bar',
'quux' => 'quuux',
})
class TestLinko < Test::Unit::TestCase
def assert_linko(expected, string)
assert_equal expected, Linko.new(string).to_html
end
def test_pass_thru
assert_linko "foo", "foo"
assert_linko "this is HTML",
"this is HTML"
end
def test_single_replacement
assert_linko 'this is foo1!', 'this is foo_!'
assert_linko 'Ruby1 makes programming fun.',
'Ruby_ makes programming fun.'
end
def test_double_replacement
assert_linko 'this is foo!', 'this is foo__!'
assert_linko 'Ruby ' +
'makes programming fun.',
'Ruby__ makes programming fun.'
end
def test_html_safety
assert_linko 'this is foo1!',
'this is foo_!'
assert_linko 'this is foo1!',
'this is foo_!'
assert_linko 'this is bar',
'this is bar'
assert_linko 'this is !',
'this is !'
end
def test_fn_numbering
assert_linko 'foo1 ' <<
'Ruby2 ' <<
'Ruby2 ' <<
'foo1 ' <<
'foo1 ' <<
'Ruby2 ' <<
'quux3',
"foo_ Ruby_ Ruby_ foo_ foo_ Ruby_ quux_"
end
end