Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

69 linhas
2.0 KiB

  1. /*
  2. * The MIT License (MIT)
  3. *
  4. * Copyright (c) 2015 Ian Coleman
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, Subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all
  14. * copies or Substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. * SOFTWARE.
  23. */
  24. package strcase
  25. import (
  26. "testing"
  27. )
  28. func TestToCamel(t *testing.T) {
  29. cases := [][]string{
  30. {"test_case", "TestCase"},
  31. {"test", "Test"},
  32. {"TestCase", "TestCase"},
  33. {" test case ", "TestCase"},
  34. {"", ""},
  35. {"many_many_words", "ManyManyWords"},
  36. {"AnyKind of_string", "AnyKindOfString"},
  37. {"odd-fix", "OddFix"},
  38. {"numbers2And55with000", "Numbers2And55With000"},
  39. }
  40. for _, i := range cases {
  41. in := i[0]
  42. out := i[1]
  43. result := ToCamel(in)
  44. if result != out {
  45. t.Error("'" + result + "' != '" + out + "'")
  46. }
  47. }
  48. }
  49. func TestToLowerCamel(t *testing.T) {
  50. cases := [][]string{
  51. {"foo-bar", "fooBar"},
  52. {"TestCase", "testCase"},
  53. {"", ""},
  54. {"AnyKind of_string", "anyKindOfString"},
  55. }
  56. for _, i := range cases {
  57. in := i[0]
  58. out := i[1]
  59. result := ToLowerCamel(in)
  60. if result != out {
  61. t.Error("'" + result + "' != '" + out + "'")
  62. }
  63. }
  64. }