-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from DataDog/lloeki/improve-test
Improve encoding test
- Loading branch information
Showing
13 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
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
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 |