我有以下模块:
# encoding: utf-8
module RandomNameModule
def self.doesNothing(word)
str = ""
word.codepoints{|val|
str << val.chr
}
return str
end
end
和以下测试:
# encoding: utf-8
require 'test/unit'
require '../src/RandomNameModule.rb'
class RandomNameTests < Test::Unit::TestCase
def testDoesNothing
sorted = WordSort.word_sort("£$&")
assert_equal("£$&", sorted)
end
end
当我运行测试时,我得到一个断言失败:
<"£$&"> expected but was
<"\xA3$&">.
这是因为"£".codepoints{|x| x.chr}
返回值\xA3
我怎样才能使这个回报£