Skip to content

Commit a4b9255

Browse files
Create crc16_test.go
1 parent 495cff8 commit a4b9255

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

checksum/crc16_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package checksum
2+
3+
import "testing"
4+
5+
func TestCRC16(t *testing.T) {
6+
tests := []struct {
7+
input string
8+
expected string
9+
}{
10+
{"hello", "A001"},
11+
{"world", "B5D0"},
12+
{"golang", "A34C"},
13+
{"", "A001"},
14+
}
15+
16+
for _, tt := range tests {
17+
t.Run(tt.input, func(t *testing.T) {
18+
got := CRC16Hex(tt.input)
19+
if got != tt.expected {
20+
t.Errorf("CRC16Hex(%q) = %q; want %q", tt.input, got, tt.expected)
21+
}
22+
})
23+
}
24+
}

0 commit comments

Comments
 (0)