-
Notifications
You must be signed in to change notification settings - Fork 1
/
crc32_test.go
52 lines (44 loc) · 1.12 KB
/
crc32_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package str
import (
"testing"
"github.com/stretchr/testify/assert"
)
const (
TestCRC32TestString = "This is a string of tests. 世界"
CRC32ResultDefault = "3425437894"
CRC32ResultC = "2760337661"
CRC32ResultK = "1921250769"
CRC32ResultK2 = "1662776799"
CRC32ResultQ = "3464169987"
)
func TestCRC32(t *testing.T) {
assert.Equal(t, CRC32ResultDefault, CRC32(TestCRC32TestString))
}
func TestCRC32_C(t *testing.T) {
options := &CRC32Options{
PolynomialType: CRC32TypeC,
}
SetCRC32Options(options)
assert.Equal(t, CRC32ResultC, CRC32(TestCRC32TestString))
}
func TestCRC32_K(t *testing.T) {
options := &CRC32Options{
PolynomialType: CRC32TypeK,
}
SetCRC32Options(options)
assert.Equal(t, CRC32ResultK, CRC32(TestCRC32TestString))
}
func TestCRC32_K2(t *testing.T) {
options := &CRC32Options{
PolynomialType: CRC32TypeK2,
}
SetCRC32Options(options)
assert.Equal(t, CRC32ResultK2, CRC32(TestCRC32TestString))
}
func TestCRC32_Q(t *testing.T) {
options := &CRC32Options{
PolynomialType: CRC32TypeQ,
}
SetCRC32Options(options)
assert.Equal(t, CRC32ResultQ, CRC32(TestCRC32TestString))
}