MCPcopy
hub / github.com/segmentio/kafka-go / TestMessageCRC32

Function TestMessageCRC32

crc32_test.go:9–32  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestMessageCRC32(t *testing.T) {
10 m := message{
11 MagicByte: 1,
12 Timestamp: 42,
13 Key: nil,
14 Value: []byte("Hello World!"),
15 }
16
17 b := &bytes.Buffer{}
18 w := &writeBuffer{w: b}
19 w.write(m)
20
21 h := crc32.New(crc32.IEEETable)
22 h.Write(b.Bytes()[4:])
23
24 sum1 := h.Sum32()
25 sum2 := uint32(m.crc32(&crc32Writer{table: crc32.IEEETable}))
26
27 if sum1 != sum2 {
28 t.Error("bad CRC32:")
29 t.Logf("expected: %d", sum1)
30 t.Logf("found: %d", sum2)
31 }
32}

Callers

nothing calls this directly

Calls 5

writeMethod · 0.95
crc32Method · 0.95
BytesMethod · 0.65
WriteMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected