github.com/tunabay/go-bitarray@v1.3.1/bitarray_sha1_test.go (about) 1 // Copyright (c) 2021 Hirotsuna Mizuno. All rights reserved. 2 // Use of this source code is governed by the MIT license that can be found in 3 // the LICENSE file. 4 5 package bitarray_test 6 7 import ( 8 "bytes" 9 "testing" 10 ) 11 12 func TestBitArray_SHA1_cavp(t *testing.T) { 13 test := func(name string) { 14 tcs, err := cavpTestCases(name) 15 if err != nil { 16 t.Fatalf("failed to load test cases: %s: %s", name, err) 17 } 18 for i, tc := range tcs { 19 got := tc.ba.SHA1() 20 if !bytes.Equal(got[:], tc.md) { 21 t.Errorf("unexpected hash: %s: #%d", name, i) 22 t.Logf("mlen: %d", tc.ba.Len()) 23 t.Logf(" msg: %#b", tc.ba) 24 t.Logf(" got: %X", got) 25 t.Logf("want: %X", tc.md) 26 } 27 } 28 } 29 test("SHA1ShortMsg") 30 test("SHA1LongMsg") 31 }