You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
396 B
23 lines
396 B
2 weeks ago
|
package TestUnit
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"hash/crc32"
|
||
|
"log"
|
||
|
"testing"
|
||
|
)
|
||
|
import "goUpload/utils"
|
||
|
|
||
|
func TestCRC16CCITT(t *testing.T) {
|
||
|
crc16 := utils.NewCRC16CCITT()
|
||
|
data := []byte{0x01, 0x02, 0x03, 0x04}
|
||
|
|
||
|
result := crc16.GetWCRCin(data)
|
||
|
// 输出CRC16结果
|
||
|
log.Printf("CRC16CCITT 结果=%x", result)
|
||
|
|
||
|
crc2 := crc32.ChecksumIEEE(data)
|
||
|
// 输出校验值
|
||
|
fmt.Printf("Checksum is %x\n", crc2)
|
||
|
}
|