You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

28 lines
692 B

  1. package internal
  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. }