MCPcopy
hub / github.com/IBM/sarama / TestMurmur2

Function TestMurmur2

partitioner_test.go:322–344  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

320}
321
322func TestMurmur2(t *testing.T) {
323 // expected values verified against the Apache Kafka Java client's
324 // org.apache.kafka.common.utils.Utils.murmur2() implementation
325 testCases := []struct {
326 input string
327 expected uint32
328 }{
329 {"foo", 597841616},
330 {"bar", 988958145},
331 {"baz", 1973573280},
332 {"", 275646681},
333 {"kafka", 3496464228},
334 {"sarama", 770765511},
335 }
336 for _, tc := range testCases {
337 t.Run(fmt.Sprintf("input=%q", tc.input), func(t *testing.T) {
338 got := murmur2([]byte(tc.input))
339 if got != tc.expected {
340 t.Errorf("murmur2(%q) = %d, want %d", tc.input, got, tc.expected)
341 }
342 })
343 }
344}
345
346func TestMurmur2Partitioner(t *testing.T) {
347 partitioner := NewMurmur2Partitioner("mytopic")

Callers

nothing calls this directly

Calls 3

murmur2Function · 0.85
RunMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected