diff options
author | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-21 12:41:34 +0000 |
---|---|---|
committer | knu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-21 12:41:34 +0000 |
commit | 07a6b4cbb509f113747cf2f77a6a6a34c9a7e7d2 (patch) | |
tree | 608e4135c7b2de757fd1131e571fe6085682fc72 /test/digest | |
parent | 51d586c64e19c13a6fdfc75a860247f0835ef1a7 (diff) | |
download | ruby-07a6b4cbb509f113747cf2f77a6a6a34c9a7e7d2.tar.gz |
* ext/digest/lib/digest.rb (Digest::Class.file): Take optional
arguments that are passed to the constructor of the digest
class.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/digest')
-rwxr-xr-x | test/digest/test_digest.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/digest/test_digest.rb b/test/digest/test_digest.rb index 4b1d55e256..1af6ea3040 100755 --- a/test/digest/test_digest.rb +++ b/test/digest/test_digest.rb @@ -4,6 +4,7 @@ # $Id$ require 'test/unit' +require 'tempfile' require 'digest' %w[digest/md5 digest/rmd160 digest/sha1 digest/sha2].each do |lib| @@ -78,6 +79,16 @@ module TestDigest assert_equal(md1, md2, self.class::ALGO) end + def test_s_file + Tempfile.create("test_digest_file") { |tmpfile| + str = "hello, world.\r\n" + tmpfile.print str + tmpfile.close + + assert_equal self.class::ALGO.new.update(str), self.class::ALGO.file(tmpfile.path) + } + end + def test_instance_eval assert_nothing_raised { self.class::ALGO.new.instance_eval { update "a" } @@ -138,6 +149,20 @@ module TestDigest } end if defined?(Digest::SHA512) + class TestSHA2 < Test::Unit::TestCase + + def test_s_file + Tempfile.create("test_digest_file") { |tmpfile| + str = Data1 + tmpfile.print str + tmpfile.close + + assert_equal "cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7", Digest::SHA2.file(tmpfile.path, 384).hexdigest + } + end + + end if defined?(Digest::SHA2) + class TestRMD160 < Test::Unit::TestCase include TestDigest ALGO = Digest::RMD160 |