aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-09 01:55:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-09 01:55:43 +0000
commit86f1d706cb8836fe812a70e9828df24c9dfbe0d3 (patch)
tree077390cc8716adeb802019affef3a127b72e767a
parent583c0429faef0268146fe255593a61d5847af059 (diff)
downloadruby-86f1d706cb8836fe812a70e9828df24c9dfbe0d3.tar.gz
test_utf16.rb: refine valid_encoding tests
* test/ruby/enc/test_utf16.rb (test_utf16be_valid_encoding): assert all data and use assert_predicate. * test/ruby/enc/test_utf16.rb (test_utf16le_valid_encoding): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/enc/test_utf16.rb112
1 files changed, 62 insertions, 50 deletions
diff --git a/test/ruby/enc/test_utf16.rb b/test/ruby/enc/test_utf16.rb
index 99b48c2982..e08f2ea14e 100644
--- a/test/ruby/enc/test_utf16.rb
+++ b/test/ruby/enc/test_utf16.rb
@@ -56,59 +56,71 @@ EOT
# tests start
def test_utf16be_valid_encoding
- [
- "\x00\x00",
- "\xd7\xff",
- "\xd8\x00\xdc\x00",
- "\xdb\xff\xdf\xff",
- "\xe0\x00",
- "\xff\xff",
- ].each {|s|
- s.force_encoding("utf-16be")
- assert_equal(true, s.valid_encoding?, "#{encdump s}.valid_encoding?")
- }
- [
- "\x00",
- "\xd7",
- "\xd8\x00",
- "\xd8\x00\xd8\x00",
- "\xdc\x00",
- "\xdc\x00\xd8\x00",
- "\xdc\x00\xdc\x00",
- "\xe0",
- "\xff",
- ].each {|s|
- s.force_encoding("utf-16be")
- assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
- }
+ all_assertions do |a|
+ [
+ "\x00\x00",
+ "\xd7\xff",
+ "\xd8\x00\xdc\x00",
+ "\xdb\xff\xdf\xff",
+ "\xe0\x00",
+ "\xff\xff",
+ ].each {|s|
+ s.force_encoding("utf-16be")
+ a.for(s) {
+ assert_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
+ }
+ }
+ [
+ "\x00",
+ "\xd7",
+ "\xd8\x00",
+ "\xd8\x00\xd8\x00",
+ "\xdc\x00",
+ "\xdc\x00\xd8\x00",
+ "\xdc\x00\xdc\x00",
+ "\xe0",
+ "\xff",
+ ].each {|s|
+ s.force_encoding("utf-16be")
+ a.for(s) {
+ assert_not_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
+ }
+ }
+ end
end
def test_utf16le_valid_encoding
- [
- "\x00\x00",
- "\xff\xd7",
- "\x00\xd8\x00\xdc",
- "\xff\xdb\xff\xdf",
- "\x00\xe0",
- "\xff\xff",
- ].each {|s|
- s.force_encoding("utf-16le")
- assert_equal(true, s.valid_encoding?, "#{encdump s}.valid_encoding?")
- }
- [
- "\x00",
- "\xd7",
- "\x00\xd8",
- "\x00\xd8\x00\xd8",
- "\x00\xdc",
- "\x00\xdc\x00\xd8",
- "\x00\xdc\x00\xdc",
- "\xe0",
- "\xff",
- ].each {|s|
- s.force_encoding("utf-16le")
- assert_equal(false, s.valid_encoding?, "#{encdump s}.valid_encoding?")
- }
+ all_assertions do |a|
+ [
+ "\x00\x00",
+ "\xff\xd7",
+ "\x00\xd8\x00\xdc",
+ "\xff\xdb\xff\xdf",
+ "\x00\xe0",
+ "\xff\xff",
+ ].each {|s|
+ s.force_encoding("utf-16le")
+ a.for(s) {
+ assert_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
+ }
+ }
+ [
+ "\x00",
+ "\xd7",
+ "\x00\xd8",
+ "\x00\xd8\x00\xd8",
+ "\x00\xdc",
+ "\x00\xdc\x00\xd8",
+ "\x00\xdc\x00\xdc",
+ "\xe0",
+ "\xff",
+ ].each {|s|
+ s.force_encoding("utf-16le")
+ a.for(s) {
+ assert_not_predicate(s, :valid_encoding?, "#{encdump s}.valid_encoding?")
+ }
+ }
+ end
end
def test_strftime