naming_test.go 885 B

1234567891011121314151617181920212223242526272829303132333435
  1. package name
  2. import (
  3. "testing"
  4. "github.com/stretchr/testify/assert"
  5. )
  6. func TestIsNamingValid(t *testing.T) {
  7. style, valid := IsNamingValid("")
  8. assert.True(t, valid)
  9. assert.Equal(t, NamingLower, style)
  10. _, valid = IsNamingValid("lower1")
  11. assert.False(t, valid)
  12. _, valid = IsNamingValid("lower")
  13. assert.True(t, valid)
  14. _, valid = IsNamingValid("snake")
  15. assert.True(t, valid)
  16. _, valid = IsNamingValid("camel")
  17. assert.True(t, valid)
  18. }
  19. func TestFormatFilename(t *testing.T) {
  20. assert.Equal(t, "abc", FormatFilename("a_b_c", NamingLower))
  21. assert.Equal(t, "ABC", FormatFilename("a_b_c", NamingCamel))
  22. assert.Equal(t, "a_b_c", FormatFilename("a_b_c", NamingSnake))
  23. assert.Equal(t, "a", FormatFilename("a", NamingSnake))
  24. assert.Equal(t, "A", FormatFilename("a", NamingCamel))
  25. // no flag to convert to snake
  26. assert.Equal(t, "abc", FormatFilename("abc", NamingSnake))
  27. }