events_test.go 678 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 Zack Guo <zack.y.guo@gmail.com>. All rights reserved.
  2. // Use of this source code is governed by a MIT license that can
  3. // be found in the LICENSE file.
  4. package termui
  5. import "testing"
  6. var ps = []string{
  7. "",
  8. "/",
  9. "/a",
  10. "/b",
  11. "/a/c",
  12. "/a/b",
  13. "/a/b/c",
  14. "/a/b/c/d",
  15. "/a/b/c/d/"}
  16. func TestMatchScore(t *testing.T) {
  17. chk := func(a, b string, s bool) {
  18. if c := isPathMatch(a, b); c != s {
  19. t.Errorf("\na:%s\nb:%s\nshould:%t\nactual:%t", a, b, s, c)
  20. }
  21. }
  22. chk(ps[1], ps[1], true)
  23. chk(ps[1], ps[2], true)
  24. chk(ps[2], ps[1], false)
  25. chk(ps[4], ps[1], false)
  26. chk(ps[6], ps[2], false)
  27. chk(ps[4], ps[5], false)
  28. }
  29. func TestCrtEvt(t *testing.T) {
  30. }