mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
934f537b45
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
49 lines
1.6 KiB
Ruby
49 lines
1.6 KiB
Ruby
######################################################################
|
|
# This file is imported from the rubygems project.
|
|
# DO NOT make modifications in this repo. They _will_ be reverted!
|
|
# File a patch instead and assign it to Ryan Davis or Eric Hodel.
|
|
######################################################################
|
|
|
|
require 'rubygems/test_case'
|
|
require "rubygems/text"
|
|
|
|
class TestGemText < Gem::TestCase
|
|
include Gem::Text
|
|
|
|
def test_format_text
|
|
assert_equal "text to\nwrap", format_text("text to wrap", 8)
|
|
end
|
|
|
|
def test_format_text_indent
|
|
assert_equal " text to\n wrap", format_text("text to wrap", 8, 2)
|
|
end
|
|
|
|
def test_format_text_none
|
|
assert_equal "text to wrap", format_text("text to wrap", 40)
|
|
end
|
|
|
|
def test_format_text_none_indent
|
|
assert_equal " text to wrap", format_text("text to wrap", 40, 2)
|
|
end
|
|
|
|
def test_levenshtein_distance_add
|
|
assert_equal 2, levenshtein_distance("zentest", "zntst")
|
|
assert_equal 2, levenshtein_distance("zntst", "zentest")
|
|
end
|
|
|
|
def test_levenshtein_distance_empty
|
|
assert_equal 5, levenshtein_distance("abcde", "")
|
|
assert_equal 5, levenshtein_distance("", "abcde")
|
|
end
|
|
|
|
def test_levenshtein_distance_remove
|
|
assert_equal 3, levenshtein_distance("zentest", "zentestxxx")
|
|
assert_equal 3, levenshtein_distance("zentestxxx", "zentest")
|
|
end
|
|
|
|
def test_levenshtein_distance_replace
|
|
assert_equal 2, levenshtein_distance("zentest", "ZenTest")
|
|
assert_equal 7, levenshtein_distance("xxxxxxx", "ZenTest")
|
|
assert_equal 7, levenshtein_distance("zentest", "xxxxxxx")
|
|
end
|
|
end
|