Merge pull request #4152 from BrzVlad/misc-gc-altstack
[mono.git] / mcs / class / corlib / Test / System.Security.Cryptography / SHA384Test.cs
index 8b0e567d85af9c00513f793f5fc563d4abadb876..2c98fdfe25828e26c28a441ae55f7065d402c7df 100644 (file)
@@ -5,7 +5,7 @@
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
 // (C) 2002 Motus Technologies Inc. (http://www.motus.com)
-// (C) 2004 Novell  http://www.novell.com
+// Copyright (C) 2004, 2007-2008 Novell, Inc (http://www.novell.com)
 //
 
 using NUnit.Framework;
@@ -27,11 +27,16 @@ namespace MonoTests.System.Security.Cryptography {
 public class SHA384Test : HashAlgorithmTest {
 
        [SetUp]
-       protected override void SetUp () 
+       public override void SetUp () 
        {
                hash = SHA384.Create ();
        }
 
+       // the hash algorithm only exists as a managed implementation
+       public override bool ManagedHashImplementation {
+               get { return true; }
+       }
+
        // test vectors from NIST FIPS 186-2
 
        private string input1 = "abc";
@@ -99,8 +104,8 @@ public class SHA384Test : HashAlgorithmTest {
        public void FIPS186_a (string testName, SHA384 hash, byte[] input, byte[] result) 
        {
                byte[] output = hash.ComputeHash (input); 
-               AssertEquals (testName + ".a.1", result, output);
-               AssertEquals (testName + ".a.2", result, hash.Hash);
+               Assert.AreEqual (result, output, testName + ".a.1");
+               Assert.AreEqual (result, hash.Hash, testName + ".a.2");
                // required or next operation will still return old hash
                hash.Initialize ();
        }
@@ -108,8 +113,8 @@ public class SHA384Test : HashAlgorithmTest {
        public void FIPS186_b (string testName, SHA384 hash, byte[] input, byte[] result) 
        {
                byte[] output = hash.ComputeHash (input, 0, input.Length); 
-               AssertEquals (testName + ".b.1", result, output);
-               AssertEquals (testName + ".b.2", result, hash.Hash);
+               Assert.AreEqual (result, output, testName + ".b.1");
+               Assert.AreEqual (result, hash.Hash, testName + ".b.2");
                // required or next operation will still return old hash
                hash.Initialize ();
        }
@@ -118,8 +123,8 @@ public class SHA384Test : HashAlgorithmTest {
        {
                MemoryStream ms = new MemoryStream (input);
                byte[] output = hash.ComputeHash (ms); 
-               AssertEquals (testName + ".c.1", result, output);
-               AssertEquals (testName + ".c.2", result, hash.Hash);
+               Assert.AreEqual (result, output, testName + ".c.1");
+               Assert.AreEqual (result, hash.Hash, testName + ".c.2");
                // required or next operation will still return old hash
                hash.Initialize ();
        }
@@ -129,7 +134,8 @@ public class SHA384Test : HashAlgorithmTest {
                byte[] output = hash.TransformFinalBlock (input, 0, input.Length);
                // LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue !
                // AssertEquals( testName + ".d.1", result, output );
-               AssertEquals (testName + ".d", result, hash.Hash);
+               Assert.IsNotNull (output, testName + ".d.1");
+               Assert.AreEqual (result, hash.Hash, testName + ".d.2");
                // required or next operation will still return old hash
                hash.Initialize ();
        }
@@ -142,7 +148,8 @@ public class SHA384Test : HashAlgorithmTest {
                byte[] output = hash.TransformFinalBlock (input, input.Length - 1, 1);
                // LAMESPEC or FIXME: TransformFinalBlock doesn't return HashValue !
                // AssertEquals (testName + ".e.1", result, output);
-               AssertEquals (testName + ".e", result, hash.Hash);
+               Assert.IsNotNull (output, testName + ".e.1");
+               Assert.AreEqual (result, hash.Hash, testName + ".e.2");
                // required or next operation will still return old hash
                hash.Initialize ();
        }
@@ -157,13 +164,13 @@ public class SHA384Test : HashAlgorithmTest {
 
                // try to build the default implementation
                SHA384 hash = SHA384.Create ();
-               AssertEquals ("SHA384.Create()", hash.ToString (), defaultSHA384);
+               Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create()");
 
                // try to build, in every way, a SHA384 implementation
                hash = SHA384.Create ("SHA384");
-               AssertEquals ("SHA384.Create('SHA384')", hash.ToString (), defaultSHA384);
+               Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create('SHA384')");
                hash = SHA384.Create ("SHA-384");
-               AssertEquals ("SHA384.Create('SHA-384')", hash.ToString (), defaultSHA384);
+               Assert.AreEqual (hash.ToString (), defaultSHA384, "SHA384.Create('SHA-384')");
        }
 
        [Test]
@@ -179,7 +186,7 @@ public class SHA384Test : HashAlgorithmTest {
        {
                // try to build invalid implementation
                hash = SHA384.Create ("InvalidHash");
-               AssertNull ("SHA384.Create('InvalidHash')", hash);
+               Assert.IsNull (hash, "SHA384.Create('InvalidHash')");
        }
 
        [Test]
@@ -195,9 +202,9 @@ public class SHA384Test : HashAlgorithmTest {
        public virtual void StaticInfo () 
        {
                string className = hash.ToString ();
-               AssertEquals (className + ".HashSize", 384, hash.HashSize);
-               AssertEquals (className + ".InputBlockSize", 1, hash.InputBlockSize);
-               AssertEquals (className + ".OutputBlockSize", 1, hash.OutputBlockSize);
+               Assert.AreEqual (384, hash.HashSize, className + ".HashSize");
+               Assert.AreEqual (1, hash.InputBlockSize, className + ".InputBlockSize");
+               Assert.AreEqual (1, hash.OutputBlockSize, className + ".OutputBlockSize");
        }
 }