PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms 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
 1<cfcomponent extends="wheelsMapping.Test">
 2
 3	<cffunction name="test_$listClean_default_delim">
 4		<cfset loc.mylist = "tony,    per   ,  james    ,,, chris   , raul ,,,,  peter">
 5		<cfset loc.e = "tony,per,james,chris,raul,peter">
 6		<cfset loc.r = $listClean(loc.mylist)>
 7		<cfset assert('loc.e eq loc.r')>
 8	</cffunction>
 9
10	<cffunction name="test_$listClean_provide_delim">
11		<cfset loc.mylist = "tony|    per   |  james    | chris   | raul |||  peter">
12		<cfset loc.e = "tony|per|james|chris|raul|peter">
13		<cfset loc.r = $listClean(loc.mylist, "|")>
14		<cfset assert('loc.e eq loc.r')>
15	</cffunction>
16
17	<cffunction name="test_$listClean_return_array">
18		<cfset loc.mylist = "tony,    per   ,  james    ,,, chris   , raul ,,,,  peter">
19		<cfset loc.r = $listClean(list=loc.mylist, returnAs="array")>
20		<cfset assert('IsArray(loc.r) and ArrayLen(loc.r) eq 6')>
21	</cffunction>
22	
23	<cffunction name="test_$listClean_return_struct">
24		<cfset loc.mylist = "tony,    per   ,  james    ,,, chris   , raul ,,,,  peter">
25		<cfset loc.r = $listClean(list=loc.mylist, returnAs="struct", defaultValue="#StructNew()#")>
26		<cfset assert('IsStruct(loc.r) and StructCount(loc.r) eq 6')>
27		<cfloop collection="#loc.r#" item="loc.i">
28			<cfset assert('IsStruct(loc.r[loc.i])')>
29		</cfloop>
30	</cffunction>
31
32	<cffunction name="test_$structDelete">
33		<cfset loc.a = {}>
34		<cfset loc.a.tony = "petruzzi">
35		<cfset loc.a.per = "djurner">
36		<cfset loc.a.james = "gibson">
37		<cfset loc.a.raul = "the man">
38		
39		<cfset $structDelete(loc.a, "tony,per")>
40		
41		<cfset assert('structkeyexists(loc.a, "raul")')>
42		<cfset assert('structkeyexists(loc.a, "james")')>
43		<cfset assert('!structkeyexists(loc.a, "tony")')>
44		<cfset assert('!structkeyexists(loc.a, "per")')>
45		
46	</cffunction>
47	
48</cfcomponent>