Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

move some i18n/localization tests to separate, duplicatable test file

  • Loading branch information...
commit 09a195fff85f06a550afb30be05d1905655541c3 1 parent e267381
@rsl authored
Showing with 83 additions and 0 deletions.
  1. +83 −0 test/i18n/default_localization_test.rb
View
83 test/i18n/default_localization_test.rb
@@ -0,0 +1,83 @@
+# encoding: UTF-8
+
+require 'test_helper'
+
+class DefaultLocalizationTest < Test::Unit::TestCase
+ def setup
+ Stringex::Localization.reset!
+
+ Stringex::Localization.backend = :internal
+ end
+
+ def test_convert_miscellaneous_characters
+ {
+ "Foo & bar make foobar" => "Foo and bar make foobar",
+ "Breakdown #9" => "Breakdown number 9",
+ "foo@bar.com" => "foo at bar dot com",
+ "100% of yr love" => "100 percent of yr love",
+ "Kisses are $3.25 each" => "Kisses are 3 dollars 25 cents each",
+ "That CD is £3.25 plus tax" => "That CD is 3 pounds 25 pence plus tax",
+ "This CD is ¥1000 instead" => "This CD is 1000 yen instead",
+ "In Europe you can buy it for €2 or €4.10" => "In Europe you can buy it for 2 euros or 4 euros 10 cents",
+ "Food+Drink" => "Food plus Drink",
+ "this & that #2 @ bla.bla for $3" => "this and that number 2 at bla dot bla for 3 dollars",
+ "three + four ÷ 40 ° fahrenheit... end" => "three plus four divide 40 degrees fahrenheit dot dot dot end",
+ "£4 but ¥5 * 100% = two" => "4 pounds but 5 yen star 100 percent equals two"
+ }.each do |misc, plain|
+ assert_equal plain, misc.convert_miscellaneous_characters
+ end
+ end
+
+ def test_convert_miscellaneous_html_entities
+ {
+ "America&#8482;" => "America(tm)",
+ "Tea &amp; Sympathy" => "Tea and Sympathy",
+ "To be continued&#8230;" => "To be continued...",
+ "Foo&nbsp;Bar" => "Foo Bar",
+ "100&#163;" => "100 pound",
+ "35&deg;" => "35 degrees"
+ }.each do |entitied, plain|
+ assert_equal plain, entitied.convert_miscellaneous_html_entities
+ end
+ end
+
+ def test_convert_vulgar_fractions
+ {
+ "&frac14;" => "one fourth",
+ "¼" => "one fourth",
+ "&#188;" => "one fourth",
+ "&frac12;" => "half",
+ "½" => "half",
+ "&#189;" => "half",
+ "&frac34;" => "three fourths",
+ "¾" => "three fourths",
+ "&#190;" => "three fourths",
+ "" => "one third",
+ "&#8531;" => "one third",
+ "" => "two thirds",
+ "&#8532;" => "two thirds",
+ "" => "one fifth",
+ "&#8533;" => "one fifth",
+ "" => "two fifths",
+ "&#8534;" => "two fifths",
+ "" => "three fifths",
+ "&#8535;" => "three fifths",
+ "" => "four fifths",
+ "&#8536;" => "four fifths",
+ "" => "one sixth",
+ "&#8537;" => "one sixth",
+ "" => "five sixths",
+ "&#8538;" => "five sixths",
+ "" => "one eighth",
+ "&#8539;" => "one eighth",
+ "" => "three eighths",
+ "&#8540;" => "three eighths",
+ "" => "five eighths",
+ "&#8541;" => "five eighths",
+ "" => "seven eighths",
+ "&#8542;" => "seven eighths"
+ }.each do |entitied, plain|
+ assert_equal plain, entitied.convert_vulgar_fractions
+ end
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.