cedlemo 2017-08-10 01:43:06 +0900 (Thu, 10 Aug 2017)
New Revision: 0fcb445613527c96a5a56c7a288d3b6d9ef0cee8
https://github.com/ruby-gnome2/ruby-gnome2/commit/0fcb445613527c96a5a56c7a288d3b6d9ef0cee8
Merged a9d8e5e: Merge pull request #1094 from cedlemo/poppler_lib_page_find_text
Message:
Add tests for new Poppler::Page#find_text
Modified files:
poppler/test/test-page.rb
Modified: poppler/test/test-page.rb (+33 -0)
===================================================================
--- poppler/test/test-page.rb 2017-08-10 01:42:38 +0900 (cf545def7)
+++ poppler/test/test-page.rb 2017-08-10 01:43:06 +0900 (65984f546)
@@ -49,6 +49,39 @@ class TestPage < Test::Unit::TestCase
layout[0].to_a.collect(&:round))
end
+ sub_test_case("#find_text") do
+ test "no options" do
+ document = Poppler::Document.new(multiple_pages_pdf)
+ page = document[0]
+ texts = page.find_text("firs")
+ assert_equal(1, texts.size)
+ assert_kind_of(Poppler::Rectangle, texts[0])
+ end
+
+ test "with default option" do
+ document = Poppler::Document.new(multiple_pages_pdf)
+ page = document[0]
+ texts = page.find_text("firs", :default)
+ assert_equal(1, texts.size)
+ assert_kind_of(Poppler::Rectangle, texts[0])
+ end
+
+ test "with options and bad text" do
+ document = Poppler::Document.new(multiple_pages_pdf)
+ page = document[0]
+ texts = page.find_text("fIrs", [:whole_words_only, :case_sensitive])
+ assert_equal(0, texts.size)
+ end
+
+ test "with options and good text" do
+ document = Poppler::Document.new(multiple_pages_pdf)
+ page = document[0]
+ texts = page.find_text("first", [:whole_words_only, :case_sensitive])
+ assert_equal(1, texts.size)
+ assert_kind_of(Poppler::Rectangle, texts[0])
+ end
+ end
+
private
def find_first_image_mapping(document)
document.each do |page|
|