Skip to content

Commit

Permalink
Improve encoding test
Browse files Browse the repository at this point in the history
  • Loading branch information
lloeki committed Nov 20, 2024
1 parent 725aab3 commit 0d8de89
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions test/engines/test_encoding.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
require 'minitest/autorun'
require "minitest/autorun"

# polyfill for Ruby 2.2 and down, used by minitest
unless "".respond_to?(:match?)
String.instance_eval do
def match?(other)
(Regexp === other) ? other.match?(self) : (self == other)
end
end
end

class TestEncoding < Minitest::Test
def test_utf8
assert_equal("".encoding, Encoding::UTF_8)
def test_utf8_lang
assert_equal("en_US.UTF-8", ENV["LANG"])
end

def test_utf8_string
assert_equal(Encoding::UTF_8, "".encoding)
end

def test_read_utf8
contents = File.read('test/fixtures/encoding/utf-8.txt')
assert_equal(contents.encoding, Encoding::UTF_8)
assert_equal(contents, "\u2705\n")
contents = File.read("test/fixtures/encoding/utf-8.txt")

assert_equal(Encoding::UTF_8, contents.encoding)
assert_equal("\u2705\n", contents)
end
end

0 comments on commit 0d8de89

Please sign in to comment.