mapper_test.go 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package core
  2. import (
  3. "testing"
  4. )
  5. func TestGonicMapperFromObj(t *testing.T) {
  6. testCases := map[string]string{
  7. "HTTPLib": "http_lib",
  8. "id": "id",
  9. "ID": "id",
  10. "IDa": "i_da",
  11. "iDa": "i_da",
  12. "IDAa": "id_aa",
  13. "aID": "a_id",
  14. "aaID": "aa_id",
  15. "aaaID": "aaa_id",
  16. "MyREalFunkYLONgNAME": "my_r_eal_funk_ylo_ng_name",
  17. }
  18. for in, expected := range testCases {
  19. out := gonicCasedName(in)
  20. if out != expected {
  21. t.Errorf("Given %s, expected %s but got %s", in, expected, out)
  22. }
  23. }
  24. }
  25. func TestGonicMapperToObj(t *testing.T) {
  26. testCases := map[string]string{
  27. "http_lib": "HTTPLib",
  28. "id": "ID",
  29. "ida": "Ida",
  30. "id_aa": "IDAa",
  31. "aa_id": "AaID",
  32. "my_r_eal_funk_ylo_ng_name": "MyREalFunkYloNgName",
  33. }
  34. for in, expected := range testCases {
  35. out := LintGonicMapper.Table2Obj(in)
  36. if out != expected {
  37. t.Errorf("Given %s, expected %s but got %s", in, expected, out)
  38. }
  39. }
  40. }