github.phpd.cn/cilium/cilium@v1.6.12/pkg/crypto/sha1/sha1_test.go (about) 1 // Copyright 2019 Authors of Cilium 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // +build !privileged_tests 16 17 package sha1 18 19 import ( 20 "math/rand" 21 "testing" 22 23 "github.com/cilium/cilium/pkg/checker" 24 25 . "gopkg.in/check.v1" 26 ) 27 28 // Hook up gocheck into the "go test" runner. 29 type Sha1TestSuite struct{} 30 31 var _ = Suite(&Sha1TestSuite{}) 32 33 func Test(t *testing.T) { 34 TestingT(t) 35 } 36 37 func (s *Sha1TestSuite) TestCopy(c *C) { 38 input := make([]byte, 256) 39 _, err := rand.Read(input) 40 c.Assert(err, IsNil) 41 42 h1 := New() 43 h1.Write(input) 44 h2 := New() 45 h2.Write(input) 46 c.Assert(h1, checker.DeepEquals, h2) 47 c.Assert(h1.String(), Equals, h2.String()) 48 49 h2.Write(input) 50 c.Assert(h1.String(), Not(Equals), h2.String()) 51 }