2018-04-26 12:31:37 +03:00
|
|
|
require_relative "helper"
|
|
|
|
|
2016-12-31 15:17:45 +02:00
|
|
|
module Parfait
|
2018-04-26 12:31:37 +03:00
|
|
|
class TestEmptyWord < ParfaitTest
|
2015-05-15 16:45:36 +03:00
|
|
|
|
2018-04-26 12:31:37 +03:00
|
|
|
def setup
|
2019-02-08 23:03:23 +02:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-04-26 12:31:37 +03:00
|
|
|
@word = Parfait::Word.new(0)
|
2015-05-15 16:45:36 +03:00
|
|
|
end
|
2018-04-26 12:31:37 +03:00
|
|
|
def test_word_create
|
|
|
|
assert @word.empty?
|
|
|
|
end
|
|
|
|
def test_empty_is_zero
|
|
|
|
assert_equal 0 , @word.length
|
|
|
|
end
|
|
|
|
def test_empty_is_zero_internal
|
|
|
|
assert_equal 0 , @word.char_length
|
|
|
|
end
|
|
|
|
def test_index_check_get
|
|
|
|
assert_raises RuntimeError do
|
|
|
|
@word.get_char(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def test_index_check_set
|
|
|
|
assert_raises RuntimeError do
|
|
|
|
@word.set_char(1 , 32)
|
|
|
|
end
|
2015-05-15 16:45:36 +03:00
|
|
|
end
|
2020-03-28 22:47:04 +05:30
|
|
|
def test_insert_1
|
2020-03-28 20:04:59 +05:30
|
|
|
a = Parfait.new_word("abc")
|
|
|
|
b = Parfait.new_word("d")
|
|
|
|
ans = Parfait.new_word("abcd")
|
|
|
|
assert_equal ans, a.insert(-1,b)
|
2020-03-28 22:47:04 +05:30
|
|
|
end
|
|
|
|
def test_insert_2
|
2020-03-28 20:04:59 +05:30
|
|
|
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)
|
2020-03-28 22:47:04 +05:30
|
|
|
end
|
|
|
|
def test_insert_3
|
2020-03-28 20:04:59 +05:30
|
|
|
a2 = Parfait.new_word("life")
|
|
|
|
b2 = Parfait.new_word("sad ")
|
|
|
|
ans = Parfait.new_word("sad life")
|
|
|
|
assert_equal ans, a2.insert(0, b2)
|
|
|
|
end
|
2015-05-15 16:45:36 +03:00
|
|
|
end
|
|
|
|
end
|