]> Cypherpunks.ru repositories - gogost.git/blobdiff - internal/gost34112012/hash_test.go
Use more modern Go version
[gogost.git] / internal / gost34112012 / hash_test.go
index 27c394b70c67a62183f29bf0f4613541bba4abdd..1473d879eaf7107e269771a42f176701ff724319 100644 (file)
@@ -47,7 +47,7 @@ func TestVectors(t *testing.T) {
                        0x36, 0x37, 0x38, 0x39, 0x30, 0x31, 0x32,
                }
                h512.Write(m)
-               if bytes.Compare(h512.Sum(nil), []byte{
+               if !bytes.Equal(h512.Sum(nil), []byte{
                        0x1b, 0x54, 0xd0, 0x1a, 0x4a, 0xf5, 0xb9, 0xd5,
                        0xcc, 0x3d, 0x86, 0xd6, 0x8d, 0x28, 0x54, 0x62,
                        0xb1, 0x9a, 0xbc, 0x24, 0x75, 0x22, 0x2f, 0x35,
@@ -56,16 +56,16 @@ func TestVectors(t *testing.T) {
                        0x38, 0x4c, 0x65, 0x74, 0xf0, 0x24, 0xc3, 0x11,
                        0xe2, 0xa4, 0x81, 0x33, 0x2b, 0x08, 0xef, 0x7f,
                        0x41, 0x79, 0x78, 0x91, 0xc1, 0x64, 0x6f, 0x48,
-               }) != 0 {
+               }) {
                        t.FailNow()
                }
                h256.Write(m)
-               if bytes.Compare(h256.Sum(nil), []byte{
+               if !bytes.Equal(h256.Sum(nil), []byte{
                        0x9d, 0x15, 0x1e, 0xef, 0xd8, 0x59, 0x0b, 0x89,
                        0xda, 0xa6, 0xba, 0x6c, 0xb7, 0x4a, 0xf9, 0x27,
                        0x5d, 0xd0, 0x51, 0x02, 0x6b, 0xb1, 0x49, 0xa4,
                        0x52, 0xfd, 0x84, 0xe5, 0xe5, 0x7b, 0x55, 0x00,
-               }) != 0 {
+               }) {
                        t.FailNow()
                }
        })
@@ -87,7 +87,7 @@ func TestVectors(t *testing.T) {
                        0x20, 0xc8, 0xe3, 0xee, 0xf0, 0xe5, 0xe2, 0xfb,
                }
                h512.Write(m)
-               if bytes.Compare(h512.Sum(nil), []byte{
+               if !bytes.Equal(h512.Sum(nil), []byte{
                        0x1e, 0x88, 0xe6, 0x22, 0x26, 0xbf, 0xca, 0x6f,
                        0x99, 0x94, 0xf1, 0xf2, 0xd5, 0x15, 0x69, 0xe0,
                        0xda, 0xf8, 0x47, 0x5a, 0x3b, 0x0f, 0xe6, 0x1a,
@@ -96,16 +96,16 @@ func TestVectors(t *testing.T) {
                        0x62, 0x0f, 0xcd, 0x7c, 0x49, 0x6c, 0xe5, 0xb3,
                        0x3f, 0x0c, 0xb9, 0xdd, 0xdc, 0x2b, 0x64, 0x60,
                        0x14, 0x3b, 0x03, 0xda, 0xba, 0xc9, 0xfb, 0x28,
-               }) != 0 {
+               }) {
                        t.FailNow()
                }
                h256.Write(m)
-               if bytes.Compare(h256.Sum(nil), []byte{
+               if !bytes.Equal(h256.Sum(nil), []byte{
                        0x9d, 0xd2, 0xfe, 0x4e, 0x90, 0x40, 0x9e, 0x5d,
                        0xa8, 0x7f, 0x53, 0x97, 0x6d, 0x74, 0x05, 0xb0,
                        0xc0, 0xca, 0xc6, 0x28, 0xfc, 0x66, 0x9a, 0x74,
                        0x1d, 0x50, 0x06, 0x3c, 0x55, 0x7e, 0x8f, 0x50,
-               }) != 0 {
+               }) {
                        t.FailNow()
                }
        })
@@ -133,12 +133,12 @@ func TestVectors(t *testing.T) {
                        0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
                }
                h256.Write(m)
-               if bytes.Compare(h256.Sum(nil), []byte{
+               if !bytes.Equal(h256.Sum(nil), []byte{
                        0xc7, 0x66, 0x08, 0x55, 0x40, 0xca, 0xaa, 0x89,
                        0x53, 0xbf, 0xcf, 0x7a, 0x1b, 0xa2, 0x20, 0x61,
                        0x9c, 0xee, 0x50, 0xd6, 0x5d, 0xc2, 0x42, 0xf8,
                        0x2f, 0x23, 0xba, 0x4b, 0x18, 0x0b, 0x18, 0xe0,
-               }) != 0 {
+               }) {
                        t.FailNow()
                }
        })
@@ -151,7 +151,7 @@ func TestBlocksized(t *testing.T) {
                m[i] = byte(i)
        }
        h.Write(m)
-       if bytes.Compare(h.Sum(nil), []byte{
+       if !bytes.Equal(h.Sum(nil), []byte{
                0x2a, 0xe5, 0x81, 0xf1, 0x8a, 0xe8, 0x5e, 0x35,
                0x96, 0xc9, 0x36, 0xac, 0xbe, 0xf9, 0x10, 0xf2,
                0xed, 0x70, 0xdc, 0xf9, 0x1e, 0xd5, 0xd2, 0x4b,
@@ -160,7 +160,7 @@ func TestBlocksized(t *testing.T) {
                0xf3, 0x0d, 0x42, 0xe1, 0x6c, 0xe2, 0x55, 0x42,
                0x6f, 0xa8, 0xa1, 0x55, 0xdc, 0xb3, 0xeb, 0x82,
                0x2d, 0x92, 0x58, 0x08, 0xf7, 0xc7, 0xe3, 0x45,
-       }) != 0 {
+       }) {
                t.FailNow()
        }
 }
@@ -169,17 +169,17 @@ func TestBehaviour(t *testing.T) {
        h := New(64)
        // Sum does not change the state
        hsh1 := h.Sum(nil)
-       if bytes.Compare(h.Sum(nil), hsh1) != 0 {
+       if !bytes.Equal(h.Sum(nil), hsh1) {
                t.FailNow()
        }
        // No data equals to no state changing
        h.Write([]byte{})
-       if bytes.Compare(h.Sum(nil), hsh1) != 0 {
+       if !bytes.Equal(h.Sum(nil), hsh1) {
                t.FailNow()
        }
        // Just to be sure
        h.Write([]byte{})
-       if bytes.Compare(h.Sum(nil), hsh1) != 0 {
+       if !bytes.Equal(h.Sum(nil), hsh1) {
                t.FailNow()
        }
 }
@@ -199,21 +199,21 @@ func TestRandom(t *testing.T) {
                        h.Write([]byte{c})
                }
                d2 := h.Sum(nil)
-               if bytes.Compare(d1, d2) != 0 {
+               if !bytes.Equal(d1, d2) {
                        return false
                }
                h2Raw, err := h.MarshalBinary()
                if err != nil {
                        return false
                }
-               if bytes.Compare(h1Raw, h2Raw) != 0 {
+               if !bytes.Equal(h1Raw, h2Raw) {
                        return false
                }
                hNew := New(64)
                if err = hNew.UnmarshalBinary(h1Raw); err != nil {
                        return false
                }
-               return bytes.Compare(hNew.Sum(nil), d1) == 0
+               return bytes.Equal(hNew.Sum(nil), d1)
        }
        if err := quick.Check(f, nil); err != nil {
                t.Error(err)