/wheels/tests/global/cfml.cfc
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
- <cfcomponent extends="wheelsMapping.Test">
-
- <cffunction name="test_$listClean_default_delim">
- <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
- <cfset loc.e = "tony,per,james,chris,raul,peter">
- <cfset loc.r = $listClean(loc.mylist)>
- <cfset assert('loc.e eq loc.r')>
- </cffunction>
-
- <cffunction name="test_$listClean_provide_delim">
- <cfset loc.mylist = "tony| per | james | chris | raul ||| peter">
- <cfset loc.e = "tony|per|james|chris|raul|peter">
- <cfset loc.r = $listClean(loc.mylist, "|")>
- <cfset assert('loc.e eq loc.r')>
- </cffunction>
-
- <cffunction name="test_$listClean_return_array">
- <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
- <cfset loc.r = $listClean(list=loc.mylist, returnAs="array")>
- <cfset assert('IsArray(loc.r) and ArrayLen(loc.r) eq 6')>
- </cffunction>
-
- <cffunction name="test_$listClean_return_struct">
- <cfset loc.mylist = "tony, per , james ,,, chris , raul ,,,, peter">
- <cfset loc.r = $listClean(list=loc.mylist, returnAs="struct", defaultValue="#StructNew()#")>
- <cfset assert('IsStruct(loc.r) and StructCount(loc.r) eq 6')>
- <cfloop collection="#loc.r#" item="loc.i">
- <cfset assert('IsStruct(loc.r[loc.i])')>
- </cfloop>
- </cffunction>
-
- <cffunction name="test_$structDelete">
- <cfset loc.a = {}>
- <cfset loc.a.tony = "petruzzi">
- <cfset loc.a.per = "djurner">
- <cfset loc.a.james = "gibson">
- <cfset loc.a.raul = "the man">
-
- <cfset $structDelete(loc.a, "tony,per")>
-
- <cfset assert('structkeyexists(loc.a, "raul")')>
- <cfset assert('structkeyexists(loc.a, "james")')>
- <cfset assert('!structkeyexists(loc.a, "tony")')>
- <cfset assert('!structkeyexists(loc.a, "per")')>
-
- </cffunction>
-
- </cfcomponent>