snake_test.go 514 B

12345678910111213141516171819202122232425
  1. package test
  2. import (
  3. "testing"
  4. "github.com/ncarlier/webhookd/pkg/assert"
  5. "github.com/ncarlier/webhookd/pkg/helper"
  6. )
  7. func TestToSnakeCase(t *testing.T) {
  8. testCases := []struct {
  9. value string
  10. expected string
  11. }{
  12. {"hello-world", "hello_world"},
  13. {"helloWorld", "hello_world"},
  14. {"HelloWorld", "hello_world"},
  15. {"Hello/_World", "hello__world"},
  16. {"Hello/world", "hello_world"},
  17. }
  18. for _, tc := range testCases {
  19. value := helper.ToSnake(tc.value)
  20. assert.Equal(t, tc.expected, value, "")
  21. }
  22. }