spec/break_iterator_spec.rb in ffi-icu-0.0.5 vs spec/break_iterator_spec.rb in ffi-icu-0.0.6
- old
+ new
@@ -16,10 +16,16 @@
iterator = BreakIterator.new :word, "en_US"
iterator.text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
iterator.to_a.should == [0, 5, 6, 11, 12, 17, 18, 21, 22, 26, 27, 28, 39, 40, 51, 52, 56, 57, 58, 61, 62, 64, 65, 72, 73, 79, 80, 90, 91, 93, 94, 100, 101, 103, 104, 110, 111, 116, 117, 123, 124]
end
+ it "finds all word boundaries in a Thai string" do
+ iterator = BreakIterator.new :word, "th_TH"
+ iterator.text = "การทดลอง"
+ iterator.to_a.should == [0, 3, 8]
+ end
+
it "finds all sentence boundaries in an English string" do
iterator = BreakIterator.new :sentence, "en_US"
iterator.text = "This is a sentence. This is another sentence, with a comma in it."
iterator.to_a.should == [0, 20, 65]
end
@@ -41,9 +47,16 @@
iterator.following(3).should == 5
iterator.preceding(6).should == 5
iterator.should be_boundary(5)
iterator.should_not be_boundary(10)
+ end
+
+ it "returns an Enumerator if no block was given" do
+ iterator = BreakIterator.new :word, "nb"
+ expected = ICU.ruby19? ? Enumerator : Enumerable::Enumerator
+
+ iterator.each.should be_kind_of(expected)
end
end # BreakIterator
end # ICU