2008-09-21 12:31:15 -04:00
|
|
|
|
2008-09-21 11:37:38 -04:00
|
|
|
module MultibyteTestHelpers
|
2014-08-15 21:19:42 -04:00
|
|
|
UNICODE_STRING = 'こにちわ'.freeze
|
|
|
|
ASCII_STRING = 'ohayo'.freeze
|
|
|
|
BYTE_STRING = "\270\236\010\210\245".force_encoding("ASCII-8BIT").freeze
|
2008-09-21 11:37:38 -04:00
|
|
|
|
|
|
|
def chars(str)
|
|
|
|
ActiveSupport::Multibyte::Chars.new(str)
|
|
|
|
end
|
|
|
|
|
|
|
|
def inspect_codepoints(str)
|
|
|
|
str.to_s.unpack("U*").map{|cp| cp.to_s(16) }.join(' ')
|
|
|
|
end
|
|
|
|
|
|
|
|
def assert_equal_codepoints(expected, actual, message=nil)
|
|
|
|
assert_equal(inspect_codepoints(expected), inspect_codepoints(actual), message)
|
|
|
|
end
|
2010-07-17 02:36:40 -04:00
|
|
|
end
|