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.

42 lines
866 B

  1. package strcase
  2. import (
  3. "testing"
  4. )
  5. func TestToCamel(t *testing.T) {
  6. cases := [][]string{
  7. []string{"test_case", "TestCase"},
  8. []string{"test", "Test"},
  9. []string{"TestCase", "TestCase"},
  10. []string{" test case ", "TestCase"},
  11. []string{"", ""},
  12. []string{"many_many_words", "ManyManyWords"},
  13. []string{"AnyKind of_string", "AnyKindOfString"},
  14. []string{"odd-fix", "OddFix"},
  15. []string{"numbers2And55with000", "Numbers2And55With000"},
  16. }
  17. for _, i := range cases {
  18. in := i[0]
  19. out := i[1]
  20. result := ToCamel(in)
  21. if result != out {
  22. t.Error("'" + result + "' != '" + out + "'")
  23. }
  24. }
  25. }
  26. func TestToLowerCamel(t *testing.T) {
  27. cases := [][]string{
  28. []string{"foo-bar", "fooBar"},
  29. }
  30. for _, i := range cases {
  31. in := i[0]
  32. out := i[1]
  33. result := ToLowerCamel(in)
  34. if result != out {
  35. t.Error("'" + result + "' != '" + out + "'")
  36. }
  37. }
  38. }