[前][次][番号順一覧][スレッド一覧]

ruby-changes:14875

From: knu <ko1@a...>
Date: Wed, 24 Feb 2010 02:05:56 +0900 (JST)
Subject: [ruby-changes:14875] Ruby:r26742 (trunk): Add some more tests.

knu	2010-02-24 02:01:08 +0900 (Wed, 24 Feb 2010)

  New Revision: 26742

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26742

  Log:
    Add some more tests.

  Modified files:
    trunk/test/openssl/test_hmac.rb

Index: test/openssl/test_hmac.rb
===================================================================
--- test/openssl/test_hmac.rb	(revision 26741)
+++ test/openssl/test_hmac.rb	(revision 26742)
@@ -8,11 +8,12 @@
 
 class OpenSSL::TestHMAC < Test::Unit::TestCase
   def setup
-    @digest = OpenSSL::Digest::MD5.new
+    @digest = OpenSSL::Digest::MD5
     @key = "KEY"
     @data = "DATA"
     @h1 = OpenSSL::HMAC.new(@key, @digest)
-    @h2 = OpenSSL::HMAC.new(@key, @digest)
+    @h2 = OpenSSL::HMAC.new(@key, @digest.new)
+    @h3 = OpenSSL::HMAC.new(@key, "MD5")
   end
 
   def teardown
@@ -20,8 +21,19 @@
 
   def test_hmac
     @h1.update(@data)
+    @h2.update(@data)
+    @h3.update(@data)
+    assert_equal(@h1.digest, @h2.digest)
+    assert_equal(@h2.digest, @h3.digest)
+
     assert_equal(OpenSSL::HMAC.digest(@digest, @key, @data), @h1.digest, "digest")
     assert_equal(OpenSSL::HMAC.hexdigest(@digest, @key, @data), @h1.hexdigest, "hexdigest")
+
+    assert_equal(OpenSSL::HMAC.digest(@digest.new, @key, @data), @h2.digest, "digest")
+    assert_equal(OpenSSL::HMAC.hexdigest(@digest.new, @key, @data), @h2.hexdigest, "hexdigest")
+
+    assert_equal(OpenSSL::HMAC.digest("MD5", @key, @data), @h3.digest, "digest")
+    assert_equal(OpenSSL::HMAC.hexdigest("MD5", @key, @data), @h3.hexdigest, "hexdigest")
   end
 
   def test_dup

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]