File: commandinfo_test.go

package info (click to toggle)
golang-github-gomodule-redigo 1%3A1.9.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 460 kB
  • sloc: makefile: 2
file content (27 lines) | stat: -rw-r--r-- 689 bytes parent folder | download | duplicates (2)
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
package redis

import "testing"

func TestLookupCommandInfo(t *testing.T) {
	for _, n := range []string{"watch", "WATCH", "wAtch"} {
		if lookupCommandInfo(n) == (commandInfo{}) {
			t.Errorf("LookupCommandInfo(%q) = CommandInfo{}, expected non-zero value", n)
		}
	}
}

func benchmarkLookupCommandInfo(b *testing.B, names ...string) {
	for i := 0; i < b.N; i++ {
		for _, c := range names {
			lookupCommandInfo(c)
		}
	}
}

func BenchmarkLookupCommandInfoCorrectCase(b *testing.B) {
	benchmarkLookupCommandInfo(b, "watch", "WATCH", "monitor", "MONITOR")
}

func BenchmarkLookupCommandInfoMixedCase(b *testing.B) {
	benchmarkLookupCommandInfo(b, "wAtch", "WeTCH", "monItor", "MONiTOR")
}