Skip to content
Browse files

Fixing the input to bug 9807 test.

Text::Hyphen requires that encodings match between the input and the
pattern files. This is easy under Ruby 1.9 because all patterns have
been converted to UTF-8; the test in question needs different
input/output data based on the patterns being tested.
  • Loading branch information...
1 parent 826ff5d commit 3890bdb6d8ac7af68f2701e223f6b8dea3a38347 Austin Ziegler committed Jul 15, 2011
Showing with 33 additions and 4 deletions.
  1. +10 −0 test/data/bug_9807_latin1.rb
  2. +10 −0 test/data/bug_9807_utf-8.rb
  3. +13 −4 test/test_bugs.rb
View
10 test/data/bug_9807_latin1.rb
@@ -0,0 +1,10 @@
+# -*- encoding: latin1 -*-
+
+module TestTextHyphenData
+ def self.bug_9807_data
+ txt = "Dampfschifffahrtskapitänsmützenhalterhersteller"
+ pts = [5, 11, 17, 19, 21, 25, 28, 31, 34, 37, 40, 44]
+ viz = "Dampf-schiff-fahrts-ka-pi-täns-müt-zen-hal-ter-her-stel-ler"
+ [ txt, pts, viz ]
+ end
+end
View
10 test/data/bug_9807_utf-8.rb
@@ -0,0 +1,10 @@
+# -*- encoding: utf-8 -*-
+
+module TestTextHyphenData
+ def self.bug_9807_data
+ txt = "Dampfschifffahrtskapitänsmützenhalterhersteller"
+ pts = [5, 11, 17, 19, 21, 25, 28, 31, 34, 37, 40, 44]
+ viz = "Dampf-schiff-fahrts-ka-pi-täns-müt-zen-hal-ter-her-stel-ler"
+ [ txt, pts, viz ]
+ end
+end
View
17 test/test_bugs.rb
@@ -2,13 +2,22 @@
require 'test/unit'
require 'text-hyphen'
-class TestTextHyphen < Test::Unit::TestCase
+# The behaviour of Text::Hyphen differs based on the version and the
+# encoding. Ruby 1.8 fails if the input is not latin1 and the hyphenation
+# patterns are latin1. Ruby 1.9 always expects UTF-8 patterns.
+data_version = if RUBY_VERSION < '1.9.1'
+ 'latin1'
+ else
+ 'utf-8'
+ end
+data_path = File.join(File.dirname(__FILE__), 'data')
+load File.join(data_path, "bug_9807_#{data_version}.rb")
+
+class TestTextHyphenBugs < Test::Unit::TestCase
def test_rubyforge_9807_28498
# http://rubyforge.org/tracker/index.php?func=detail&aid=9807&group_id=294&atid=1195
# http://rubyforge.org/tracker/index.php?func=detail&aid=28498&group_id=294&atid=1195
- txt = "Dampfschifffahrtskapitänsmützenhalterhersteller"
- pts = [5, 11, 17, 19, 21, 25, 28, 31, 34, 37, 40, 44]
- viz = "Dampf-schiff-fahrts-ka-pi-täns-müt-zen-hal-ter-her-stel-ler"
+ txt, pts, viz = TestTextHyphenData.bug_9807_data
de1 = Text::Hyphen.new(:language => 'de')
assert_equal pts, de1.hyphenate(txt)

0 comments on commit 3890bdb

Please sign in to comment.
Something went wrong with that request. Please try again.