# encoding: UTF-8 require 'test_helper' require 'i18n' require 'stringex' class EnglishYAMLLocalizationTest < Test::Unit::TestCase def setup Stringex::Localization.reset! Stringex::Localization.backend = :i18n Stringex::Localization.backend.load_translations :en Stringex::Localization.locale = :en end { "foo & bar" => "foo and bar", "AT&T" => "AT and T", "99° is normal" => "99 degrees is normal", "4 ÷ 2 is 2" => "4 divided by 2 is 2", "webcrawler.com" => "webcrawler dot com", "Well..." => "Well dot dot dot", "x=1" => "x equals 1", "a #2 pencil" => "a number 2 pencil", "100%" => "100 percent", "cost+tax" => "cost plus tax", "batman/robin fan fiction" => "batman slash robin fan fiction", "dial *69" => "dial star 69", " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged " }.each do |original, converted| define_method "test_character_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_characters end end { "¤20" => "20 pounds", "$100" => "100 dollars", "$19.99" => "19 dollars 99 cents", "£100" => "100 pounds", "£19.99" => "19 pounds 99 pence", "€100" => "100 euros", "€19.99" => "19 euros 99 cents", "¥1000" => "1000 yen" }.each do |original, converted| define_method "test_currency_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_characters end end { "Tea & Sympathy" => "Tea and Sympathy", "10¢" => "10 cents", "©2000" => "(c)2000", "98° is fine" => "98 degrees is fine", "10÷5" => "10 divided by 5", ""quoted"" => '"quoted"', "to be continued…" => "to be continued...", "2000–2004" => "2000-2004", "I wish—oh, never mind" => "I wish--oh, never mind", "½ ounce of gold" => "half ounce of gold", "1 and ¼ ounces of silver" => "1 and one fourth ounces of silver", "9 and ¾ ounces of platinum" => "9 and three fourths ounces of platinum", "3>2" => "3>2", "2<3" => "2<3", "two words" => "two words", "£100" => "pounds 100", "Walmart®" => "Walmart(r)", "'single quoted'" => "'single quoted'", "2×4" => "2x4", "Programming™" => "Programming(tm)", "¥20000" => "yen 20000", " i leave whitespace on ends unchanged " => " i leave whitespace on ends unchanged " }.each do |original, converted| define_method "test_html_entity_conversion: '#{original}'" do assert_equal converted, original.convert_miscellaneous_html_entities end end { "½" => "half", "½" => "half", "½" => "half", "⅓" => "one third", "⅓" => "one third", "⅔" => "two thirds", "⅔" => "two thirds", "¼" => "one fourth", "¼" => "one fourth", "¼" => "one fourth", "¾" => "three fourths", "¾" => "three fourths", "¾" => "three fourths", "⅕" => "one fifth", "⅕" => "one fifth", "⅖" => "two fifths", "⅖" => "two fifths", "⅗" => "three fifths", "⅗" => "three fifths", "⅘" => "four fifths", "⅘" => "four fifths", "⅙" => "one sixth", "⅙" => "one sixth", "⅚" => "five sixths", "⅚" => "five sixths", "⅛" => "one eighth", "⅛" => "one eighth", "⅜" => "three eighths", "⅜" => "three eighths", "⅝" => "five eighths", "⅝" => "five eighths", "⅞" => "seven eighths", "⅞" => "seven eighths" }.each do |original, converted| define_method "test_vulgar_fractions_conversion: #{original}" do assert_equal converted, original.convert_vulgar_fractions end end end