mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
51d586c64e
commit
07a6b4cbb5
3 changed files with 35 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue