PageRenderTime 176ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/wheels/tests/global/cfml.cfc

http://cfwheels.googlecode.com/
ColdFusion CFScript | 48 lines | 39 code | 9 blank | 0 comment | 0 complexity | 0cfdf548552a25f075cc1fc1f1f14d4f MD5 | raw file
Possible License(s): Apache-2.0, CPL-1.0
  1. <cfcomponent extends="wheelsMapping.Test">
  2. <cffunction name="test_$listClean_default_delim">
  3. <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
  4. <cfset loc.e = "tony,per,james,chris,raul,peter">
  5. <cfset loc.r = $listClean(loc.mylist)>
  6. <cfset assert('loc.e eq loc.r')>
  7. </cffunction>
  8. <cffunction name="test_$listClean_provide_delim">
  9. <cfset loc.mylist = "tony| per | james | chris | raul ||| peter">
  10. <cfset loc.e = "tony|per|james|chris|raul|peter">
  11. <cfset loc.r = $listClean(loc.mylist, "|")>
  12. <cfset assert('loc.e eq loc.r')>
  13. </cffunction>
  14. <cffunction name="test_$listClean_return_array">
  15. <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
  16. <cfset loc.r = $listClean(list=loc.mylist, returnAs="array")>
  17. <cfset assert('IsArray(loc.r) and ArrayLen(loc.r) eq 6')>
  18. </cffunction>
  19. <cffunction name="test_$listClean_return_struct">
  20. <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
  21. <cfset loc.r = $listClean(list=loc.mylist, returnAs="struct", defaultValue="#StructNew()#")>
  22. <cfset assert('IsStruct(loc.r) and StructCount(loc.r) eq 6')>
  23. <cfloop collection="#loc.r#" item="loc.i">
  24. <cfset assert('IsStruct(loc.r[loc.i])')>
  25. </cfloop>
  26. </cffunction>
  27. <cffunction name="test_$structDelete">
  28. <cfset loc.a = {}>
  29. <cfset loc.a.tony = "petruzzi">
  30. <cfset loc.a.per = "djurner">
  31. <cfset loc.a.james = "gibson">
  32. <cfset loc.a.raul = "the man">
  33. <cfset $structDelete(loc.a, "tony,per")>
  34. <cfset assert('structkeyexists(loc.a, "raul")')>
  35. <cfset assert('structkeyexists(loc.a, "james")')>
  36. <cfset assert('!structkeyexists(loc.a, "tony")')>
  37. <cfset assert('!structkeyexists(loc.a, "per")')>
  38. </cffunction>
  39. </cfcomponent>