Merge branch 'master' of github.com:ruby-x/rubyx

This commit is contained in:
2020-03-28 19:50:26 +02:00
3 changed files with 82 additions and 1 deletions

View File

@ -26,5 +26,23 @@ module Parfait
@word.set_char(1 , 32)
end
end
def test_insert_1
a = Parfait.new_word("abc")
b = Parfait.new_word("d")
ans = Parfait.new_word("abcd")
assert_equal ans, a.insert(-1,b)
end
def test_insert_2
a1 = Parfait.new_word("what name")
b1 = Parfait.new_word("is your ")
ans = Parfait.new_word("what is your name")
assert_equal ans, a1.insert(5, b1)
end
def test_insert_3
a2 = Parfait.new_word("life")
b2 = Parfait.new_word("sad ")
ans = Parfait.new_word("sad life")
assert_equal ans, a2.insert(0, b2)
end
end
end

View File

@ -6,6 +6,7 @@ module Parfait
super
@word = Parfait::Word.new(5)
end
def test_len
assert_equal 5 , @word.length
end
@ -83,6 +84,28 @@ module Parfait
two = Parfait.new_word("one")
assert one.compare(two)
end
def test_start_with1
one = Parfait.new_word("Hello")
two = Parfait.new_word("Hel")
assert one.start_with(two)
end
def test_start_with2
one = Parfait.new_word("Vanilla")
two = Parfait.new_word("Va")
assert one.start_with(two)
end
def test_start_with3
one = Parfait.new_word("hello")
two = Parfait.new_word("hellooo")
assert_equal false, one.start_with(two)
end
def test_start_with4
one = Parfait.new_word("bajjs")
two = Parfait.new_word("bgjj")
assert_equal false, one.start_with(two)
end
def test_first_char
one = Parfait.new_word("one")
one.set_char(0 , "T".ord)