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.

39 lines
858 B

  1. package formattools
  2. import (
  3. "github.com/stretchr/testify/assert"
  4. "testing"
  5. )
  6. func TestCompactMatch(t *testing.T) {
  7. table := []struct {
  8. O string
  9. I []string
  10. }{
  11. {
  12. "nanoleaf:172.16.119.33:{abcd,dead,beef,0000}",
  13. []string{
  14. "nanoleaf:172.16.119.33:abcd", "nanoleaf:172.16.119.33:dead",
  15. "nanoleaf:172.16.119.33:beef", "nanoleaf:172.16.119.33:0000",
  16. },
  17. },
  18. {
  19. "nanoleaf:172.16.{119.33:abcd,22.33:dead}",
  20. []string{
  21. "nanoleaf:172.16.119.33:abcd", "nanoleaf:172.16.22.33:dead",
  22. },
  23. },
  24. {
  25. "{nanoleaf:172.16.119.33:abcd,hue:172.16.119.34:81bd3cc3-cf22-4401-a5cb-a4bf18687270}",
  26. []string{
  27. "nanoleaf:172.16.119.33:abcd", "hue:172.16.119.34:81bd3cc3-cf22-4401-a5cb-a4bf18687270",
  28. },
  29. },
  30. }
  31. for _, row := range table {
  32. t.Run(row.O, func(t *testing.T) {
  33. assert.Equal(t, row.O, CompactMatch(row.I))
  34. })
  35. }
  36. }