PageRenderTime 47ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/global/strings.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 92 lines | 75 code | 17 blank | 0 comment | 0 complexity | 01741e1ca94cce05e138fd6d233ee407 MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_singularize">
  3. <cfset loc.result = singularize("statuses")>
  4. <cfset assert("NOT Compare(loc.result, 'status')")>
  5. </cffunction>
  6. <cffunction name="test_singularize_starting_with_upper_case">
  7. <cfset loc.result = singularize("Instances")>
  8. <cfset assert("NOT Compare(loc.result, 'Instance')")>
  9. </cffunction>
  10. <cffunction name="test_singularize_two_words">
  11. <cfset loc.result = singularize("statusUpdates")>
  12. <cfset assert("NOT Compare(loc.result, 'statusUpdate')")>
  13. </cffunction>
  14. <cffunction name="test_singularize_multiple_words">
  15. <cfset loc.result = singularize("fancyChristmasTrees")>
  16. <cfset assert("NOT Compare(loc.result, 'fancyChristmasTree')")>
  17. </cffunction>
  18. <cffunction name="test_pluralize">
  19. <cfset loc.result = pluralize("status")>
  20. <cfset assert("NOT Compare(loc.result, 'statuses')")>
  21. </cffunction>
  22. <cffunction name="test_pluralize_with_count">
  23. <cfset loc.result = pluralize("statusUpdate", 0)>
  24. <cfset assert("NOT Compare(loc.result, '0 statusUpdates')")>
  25. <cfset loc.result = pluralize("statusUpdate", 1)>
  26. <cfset assert("NOT Compare(loc.result, '1 statusUpdate')")>
  27. <cfset loc.result = pluralize("statusUpdate", 2)>
  28. <cfset assert("NOT Compare(loc.result, '2 statusUpdates')")>
  29. </cffunction>
  30. <cffunction name="test_pluralize_starting_with_upper_case">
  31. <cfset loc.result = pluralize("Instance")>
  32. <cfset assert("NOT Compare(loc.result, 'Instances')")>
  33. </cffunction>
  34. <cffunction name="test_pluralize_two_words">
  35. <cfset loc.result = pluralize("statusUpdate")>
  36. <cfset assert("NOT Compare(loc.result, 'statusUpdates')")>
  37. </cffunction>
  38. <cffunction name="test_pluralize_issue_450">
  39. <cfset loc.result = pluralize("statuscode")>
  40. <cfset assert("NOT Compare(loc.result, 'statuscodes')")>
  41. </cffunction>
  42. <cffunction name="test_pluralize_multiple_words">
  43. <cfset loc.result = pluralize("fancyChristmasTree")>
  44. <cfset assert("NOT Compare(loc.result, 'fancyChristmasTrees')")>
  45. </cffunction>
  46. <cffunction name="test_hyphenize_normal_variable">
  47. <cfset loc.result = hyphenize("wheelsIsAFramework")>
  48. <cfset assert("NOT Compare(loc.result, 'wheels-is-a-framework')")>
  49. </cffunction>
  50. <cffunction name="test_hyphenize_variable_starting_with_uppercase">
  51. <cfset loc.result = hyphenize("WheelsIsAFramework")>
  52. <cfset debug('loc.result', false)>
  53. <cfset assert("NOT Compare(loc.result, 'wheels-is-a-framework')")>
  54. </cffunction>
  55. <cffunction name="test_hyphenize_variable_with_abbreviation">
  56. <cfset loc.result = hyphenize("aURLVariable")>
  57. <cfset debug('loc.result', false)>
  58. <cfset assert("NOT Compare(loc.result, 'a-url-variable')")>
  59. </cffunction>
  60. <cffunction name="test_hyphenize_variable_with_abbreviation_starting_with_uppercase">
  61. <cfset loc.result = hyphenize("URLVariable")>
  62. <cfset debug('loc.result', false)>
  63. <cfset assert("NOT Compare(loc.result, 'url-variable')")>
  64. </cffunction>
  65. <cffunction name="test_hyphenize_should_only_insert_hyphens_in_mixed_case">
  66. <cfset loc.result = hyphenize("ERRORMESSAGE")>
  67. <cfset assert("NOT Compare(loc.result, 'errormessage')")>
  68. <cfset loc.result = hyphenize("errormessage")>
  69. <cfset assert("NOT Compare(loc.result, 'errormessage')")>
  70. </cffunction>
  71. <cffunction name="test_singularize_of_address">
  72. <cfset loc.result = singularize("address")>
  73. <cfset assert("NOT Compare(loc.result, 'address')")>
  74. </cffunction>
  75. </cfcomponent>