gitee.com/gricks/utils@v1.0.8/crc32_test.go (about)

     1  package utils
     2  
     3  import (
     4  	"io/ioutil"
     5  	"math/rand"
     6  	"testing"
     7  
     8  	. "github.com/smartystreets/goconvey/convey"
     9  )
    10  
    11  func Test_Crc32(t *testing.T) {
    12  	Convey("CRC32", t, func() {
    13  		b, err := ioutil.ReadFile("crc32_test.go")
    14  		So(err, ShouldBeNil)
    15  		p := rand.Intn(len(b)-len(b)/2) + len(b)/4
    16  		b1 := b[:p]
    17  		b2 := b[p:]
    18  		v1 := NewCRC(b).Value()
    19  		v2 := NewCRC(b1).Append(b2).Value()
    20  		So(v1, ShouldEqual, v2)
    21  	})
    22  }