2017-07-09 08:06:36 -04:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 09:39:13 -04:00
|
|
|
|
2008-09-21 11:37:38 -04:00
|
|
|
module MultibyteTestHelpers
|
2018-02-27 23:33:37 -05:00
|
|
|
UNICODE_STRING = "こにちわ"
|
|
|
|
ASCII_STRING = "ohayo"
|
2018-05-17 04:32:27 -04:00
|
|
|
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)
|
2016-08-16 03:30:11 -04:00
|
|
|
str.to_s.unpack("U*").map { |cp| cp.to_s(16) }.join(" ")
|
2008-09-21 11:37:38 -04:00
|
|
|
end
|
|
|
|
|
2016-10-28 23:05:58 -04:00
|
|
|
def assert_equal_codepoints(expected, actual, message = nil)
|
2008-09-21 11:37:38 -04:00
|
|
|
assert_equal(inspect_codepoints(expected), inspect_codepoints(actual), message)
|
|
|
|
end
|
2010-07-17 02:36:40 -04:00
|
|
|
end
|