Created
September 16, 2008 13:44
-
-
Save seebq/11037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require File.dirname(__FILE__) + '/../test_helper' | |
class HebrewReversalTest < Test::Unit::TestCase | |
def setup | |
@single_line_string = "I should be reversed." | |
@multi_line_string = "I should be reversed. \nAnd I should too. \nAlong with me!" | |
end | |
# helper to reverse strings if the language is rtl | |
def reverse_rtl(str) | |
# if Locale.language.direction == "rtl" | |
reversed_lines = [] | |
reversed_string = "" | |
lines = str.split("\n").reverse.join("\n") | |
lines.each do |line| | |
line.each_char do |x| | |
reversed_string.insert(0, x) | |
end | |
end | |
return reversed_string | |
# else | |
# return str | |
# end | |
end | |
def test_reverse_single_line | |
assert_equal ".desrever eb dluohs I", reverse_rtl(@single_line_string) | |
end | |
def test_reverse_multi_line | |
assert_equal " .desrever eb dluohs I\n .oot dluohs I dnA\n!em htiw gnolA", reverse_rtl(@multi_line_string) | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment