github.com/waltonchain/waltonchain_gwtc_src@v1.1.4-0.20201225072101-8a298c95a819/crypto/x11/nist/nist_test.go (about) 1 // Use of this source code is governed by an ISC 2 // license that can be found in the LICENSE file. 3 4 package nist 5 6 import "testing" 7 8 //////////////// 9 10 func TestGet(t *testing.T) { 11 if ln := len(Get(0)); 0 != ln { 12 t.Errorf("Get: expected length: %d, got %d", 0, ln) 13 } 14 if ln := len(Get(1)); 1 != ln { 15 t.Errorf("Get: expected length: %d, got %d", 1, ln) 16 } 17 } 18 19 func TestHashIsEqual(t *testing.T) { 20 var a = []byte{0x00, 0x01} 21 var b = []byte{0x00, 0x01} 22 var c = []byte{0x01, 0x02} 23 var d = []byte{0x01, 0x02, 0x03} 24 25 if !IsEqual(a, a) { 26 t.Errorf("HashIsEqual: expected true, got false") 27 } 28 if !IsEqual(a, b) { 29 t.Errorf("HashIsEqual: expected true, got false") 30 } 31 if IsEqual(a, c) { 32 t.Errorf("HashIsEqual: expected false, got true") 33 } 34 if IsEqual(c, d) { 35 t.Errorf("HashIsEqual: expected false, got true") 36 } 37 if IsEqual(a, nil) { 38 t.Errorf("HashIsEqual: expected false, got true") 39 } 40 if IsEqual(nil, b) { 41 t.Errorf("HashIsEqual: expected false, got true") 42 } 43 if !IsEqual(nil, nil) { 44 t.Errorf("HashIsEqual: expected true, got false") 45 } 46 }