1
require 'rubygems/test_case'
2
require "rubygems/text"
4
class TestGemText < Gem::TestCase
8
assert_equal "text to\nwrap", format_text("text to wrap", 8)
11
def test_format_text_indent
12
assert_equal " text to\n wrap", format_text("text to wrap", 8, 2)
15
def test_format_text_none
16
assert_equal "text to wrap", format_text("text to wrap", 40)
19
def test_format_text_none_indent
20
assert_equal " text to wrap", format_text("text to wrap", 40, 2)
23
def test_format_text_trailing # for two spaces after .
25
This line is really, really long. So long, in fact, that it is more than eighty characters long! The purpose of this line is for testing wrapping behavior because sometimes people don't wrap their text to eighty characters. Without the wrapping, the text might not look good in the RSS feed.
28
expected = <<-EXPECTED
29
This line is really, really long. So long, in fact, that it is more than
30
eighty characters long! The purpose of this line is for testing wrapping
31
behavior because sometimes people don't wrap their text to eighty characters.
32
Without the wrapping, the text might not look good in the RSS feed.
35
assert_equal expected, format_text(text, 78)
38
def test_levenshtein_distance_add
39
assert_equal 2, levenshtein_distance("zentest", "zntst")
40
assert_equal 2, levenshtein_distance("zntst", "zentest")
43
def test_levenshtein_distance_empty
44
assert_equal 5, levenshtein_distance("abcde", "")
45
assert_equal 5, levenshtein_distance("", "abcde")
48
def test_levenshtein_distance_remove
49
assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
50
assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
53
def test_levenshtein_distance_replace
54
assert_equal 2, levenshtein_distance("zentest", "ZenTest")
55
assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
56
assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")