summaryrefslogtreecommitdiff
path: root/test/digest
diff options
context:
space:
mode:
authoreregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-01 13:30:51 +0000
committereregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-01 13:30:51 +0000
commit61b624d149204c2b1c17a2852d088b2eb2aa010b (patch)
tree2751b726a511d78ff7b893c93824f960fbd83a13 /test/digest
parentf52eefece1c24503c607be7b059fe82639f128f7 (diff)
ext/digest/digest.c (hexencode_str_new): return an ASCII string
* test/digest: tests for all kind of digests encodings [ruby-core:46792][Bug #6799] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/digest')
-rwxr-xr-xtest/digest/test_digest.rb12
-rw-r--r--test/digest/test_digest_extend.rb1
2 files changed, 10 insertions, 3 deletions
diff --git a/test/digest/test_digest.rb b/test/digest/test_digest.rb
index 6611290..4b1d55e 100755
--- a/test/digest/test_digest.rb
+++ b/test/digest/test_digest.rb
@@ -25,21 +25,27 @@ module TestDigest
def test_s_hexdigest
self.class::DATA.each do |str, hexdigest|
- assert_equal(hexdigest, self.class::ALGO.hexdigest(str))
+ actual = self.class::ALGO.hexdigest(str)
+ assert_equal(hexdigest, actual)
+ assert_equal(Encoding::US_ASCII, actual.encoding)
end
end
def test_s_base64digest
self.class::DATA.each do |str, hexdigest|
digest = [hexdigest].pack("H*")
- assert_equal([digest].pack("m0"), self.class::ALGO.base64digest(str))
+ actual = self.class::ALGO.base64digest(str)
+ assert_equal([digest].pack("m0"), actual)
+ assert_equal(Encoding::US_ASCII, actual.encoding)
end
end
def test_s_digest
self.class::DATA.each do |str, hexdigest|
digest = [hexdigest].pack("H*")
- assert_equal(digest, self.class::ALGO.digest(str))
+ actual = self.class::ALGO.digest(str)
+ assert_equal(digest, actual)
+ assert_equal(Encoding::BINARY, actual.encoding)
end
end
diff --git a/test/digest/test_digest_extend.rb b/test/digest/test_digest_extend.rb
index 577fd7a..2992e28 100644
--- a/test/digest/test_digest_extend.rb
+++ b/test/digest/test_digest_extend.rb
@@ -49,6 +49,7 @@ class TestDigestExtend < Test::Unit::TestCase
(0..0xff).to_a.map { |c| sprintf("%02x", c ) }.join(''),
Digest.hexencode((0..0xff).to_a.map { |c| c.chr }.join(''))
)
+ assert_equal(Encoding::US_ASCII, Digest.hexencode("\1\2").encoding)
end
def test_class_reset