commandinfo_test.go 689 B

123456789101112131415161718192021222324252627
  1. package redis
  2. import "testing"
  3. func TestLookupCommandInfo(t *testing.T) {
  4. for _, n := range []string{"watch", "WATCH", "wAtch"} {
  5. if LookupCommandInfo(n) == (CommandInfo{}) {
  6. t.Errorf("LookupCommandInfo(%q) = CommandInfo{}, expected non-zero value", n)
  7. }
  8. }
  9. }
  10. func benchmarkLookupCommandInfo(b *testing.B, names ...string) {
  11. for i := 0; i < b.N; i++ {
  12. for _, c := range names {
  13. LookupCommandInfo(c)
  14. }
  15. }
  16. }
  17. func BenchmarkLookupCommandInfoCorrectCase(b *testing.B) {
  18. benchmarkLookupCommandInfo(b, "watch", "WATCH", "monitor", "MONITOR")
  19. }
  20. func BenchmarkLookupCommandInfoMixedCase(b *testing.B) {
  21. benchmarkLookupCommandInfo(b, "wAtch", "WeTCH", "monItor", "MONiTOR")
  22. }