mapper_test.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package core
  5. import (
  6. "testing"
  7. )
  8. func TestGonicMapperFromObj(t *testing.T) {
  9. testCases := map[string]string{
  10. "HTTPLib": "http_lib",
  11. "id": "id",
  12. "ID": "id",
  13. "IDa": "i_da",
  14. "iDa": "i_da",
  15. "IDAa": "id_aa",
  16. "aID": "a_id",
  17. "aaID": "aa_id",
  18. "aaaID": "aaa_id",
  19. "MyREalFunkYLONgNAME": "my_r_eal_funk_ylo_ng_name",
  20. }
  21. for in, expected := range testCases {
  22. out := gonicCasedName(in)
  23. if out != expected {
  24. t.Errorf("Given %s, expected %s but got %s", in, expected, out)
  25. }
  26. }
  27. }
  28. func TestGonicMapperToObj(t *testing.T) {
  29. testCases := map[string]string{
  30. "http_lib": "HTTPLib",
  31. "id": "ID",
  32. "ida": "Ida",
  33. "id_aa": "IDAa",
  34. "aa_id": "AaID",
  35. "my_r_eal_funk_ylo_ng_name": "MyREalFunkYloNgName",
  36. }
  37. for in, expected := range testCases {
  38. out := LintGonicMapper.Table2Obj(in)
  39. if out != expected {
  40. t.Errorf("Given %s, expected %s but got %s", in, expected, out)
  41. }
  42. }
  43. }