/[eiffelstudio]/trunk/eweasel/tests/set001/test.e
ViewVC logotype

Contents of /trunk/eweasel/tests/set001/test.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 65297 - (show annotations)
Thu Nov 30 20:22:33 2006 UTC (13 years ago) by manus
File size: 7147 byte(s)
Moved from trunk/Src/eweasel to trunk/eweasel so that a simple checkout of the source code is not penalized by the lenghty process of checking out all the tests of eweasel.
1 class
2 TEST
3
4 create
5
6 make
7
8 feature {NONE} -- Initialization
9
10 make is
11 -- Execute test.
12 local
13 i: INTEGER
14 do
15 create_obj_sets
16 fill_obj_sets (False, False)
17 check_obj_sets
18 create_obj_sets
19 fill_obj_sets (True, False)
20 check_obj_sets
21 create_obj_sets
22 fill_obj_sets (False, True)
23 check_obj_sets
24 create_obj_sets
25 fill_obj_sets (True, True)
26 check_obj_sets
27 create_obj_cmp_sets
28 fill_obj_cmp_sets (False, False)
29 check_obj_sets
30 create_obj_cmp_sets
31 fill_obj_cmp_sets (True, False)
32 check_obj_sets
33 create_obj_cmp_sets
34 fill_obj_cmp_sets (False, True)
35 check_obj_sets
36 create_obj_cmp_sets
37 fill_obj_cmp_sets (True, True)
38 check_obj_sets
39 from
40 i := 1
41 until
42 i > Implementations
43 loop
44 create_string_sets (i)
45 fill_string_sets (False, False)
46 check_string_sets
47 create_string_sets (i)
48 fill_string_sets (True, False)
49 check_string_sets
50 create_string_sets (i)
51 fill_string_sets (False, True)
52 check_string_sets
53 create_string_sets (i)
54 fill_string_sets (True, True)
55 check_string_sets
56 i := i + 1
57 end
58 end
59
60 feature {NONE} -- Constants
61
62 Implementations: INTEGER is 2
63 -- Number of implementations
64
65 feature {NONE} -- Implementation
66
67 obj_set1, obj_set2: TRAVERSABLE_SUBSET [SAMPLE_OBJECT]
68
69 string_set1, string_set2: TRAVERSABLE_SUBSET [STRING]
70
71 create_obj_sets is
72 -- Create object sets.
73 do
74 Io.put_string ("Create object set as type LINKED_SET%N")
75 create {LINKED_SET [SAMPLE_OBJECT]} obj_set1.make
76 create {LINKED_SET [SAMPLE_OBJECT]} obj_set2.make
77 end
78
79 create_obj_cmp_sets is
80 -- Create comparable object sets.
81 do
82 Io.put_string ("Create comparable object set as type BINARY_SEARCH_TREE_SET%N")
83 create {BINARY_SEARCH_TREE_SET [SAMPLE_OBJECT_COMPARABLE]} obj_set1.make
84 create {BINARY_SEARCH_TREE_SET [SAMPLE_OBJECT_COMPARABLE]} obj_set2.make
85 end
86
87 create_string_sets (impl: INTEGER) is
88 -- Create string sets using the implementation determined by
89 -- `impl'.
90 require
91 defined_implementation: 1 <= impl and impl <= Implementations
92 do
93 inspect
94 impl
95 when 1 then
96 Io.put_string ("Create string set as type LINKED_SET%N")
97 create {LINKED_SET [STRING]} string_set1.make
98 create {LINKED_SET [STRING]} string_set2.make
99 when 2 then
100 Io.put_string ("Create string set as type BINARY_SEARCH_TREE_SET%N")
101 create {BINARY_SEARCH_TREE_SET [STRING]} string_set1.make
102 create {BINARY_SEARCH_TREE_SET [STRING]} string_set2.make
103 end
104 end
105
106 fill_obj_sets (disjoint, obj_comparison: BOOLEAN) is
107 -- Fill object sets with (non-)disjoint data and set
108 -- `object_comparison' of the sets to `obj_comparison'.
109 require
110 sets_exist: obj_set1 /= Void and obj_set2 /= Void
111 local
112 o: SAMPLE_OBJECT
113 do
114 if obj_comparison then
115 Io.put_string ("object comparison set%N")
116 obj_set1.compare_objects
117 obj_set2.compare_objects
118 else
119 Io.put_string ("reference comparison set%N")
120 obj_set1.compare_references
121 obj_set2.compare_references
122 end
123 if disjoint then
124 Io.put_string ("Filling object set with disjoint data%N")
125 create o.make (1)
126 obj_set1.put (o)
127 create o.make (3)
128 obj_set1.put (o)
129 create o.make (6)
130 obj_set1.put (o)
131 create o.make (2)
132 obj_set2.put (o)
133 create o.make (4)
134 obj_set2.put (o)
135 create o.make (7)
136 obj_set2.put (o)
137 else
138 Io.put_string ("Filling object set with non-disjoint data%N")
139 create o.make (1)
140 obj_set1.put (o)
141 create o.make (3)
142 obj_set1.put (o)
143 create o.make (5)
144 obj_set1.put (o)
145 if obj_comparison then create o.make (5) end
146 obj_set2.put (o)
147 create o.make (2)
148 obj_set2.put (o)
149 create o.make (4)
150 obj_set2.put (o)
151 end
152 ensure
153 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
154 end
155
156 fill_obj_cmp_sets (disjoint, obj_comparison: BOOLEAN) is
157 -- Fill comparable object sets with (non-)disjoint data and set
158 -- `object_comparison' of the sets to `obj_comparison'.
159 require
160 sets_exist: obj_set1 /= Void and obj_set2 /= Void
161 local
162 o: SAMPLE_OBJECT_COMPARABLE
163 do
164 if obj_comparison then
165 Io.put_string ("object comparison set%N")
166 obj_set1.compare_objects
167 obj_set2.compare_objects
168 else
169 Io.put_string ("reference comparison set%N")
170 obj_set1.compare_references
171 obj_set2.compare_references
172 end
173 if disjoint then
174 Io.put_string ("Filling comparable object set with disjoint data%N")
175 create o.make (1)
176 obj_set1.put (o)
177 create o.make (3)
178 obj_set1.put (o)
179 create o.make (6)
180 obj_set1.put (o)
181 create o.make (2)
182 obj_set2.put (o)
183 create o.make (4)
184 obj_set2.put (o)
185 create o.make (7)
186 obj_set2.put (o)
187 else
188 Io.put_string ("Filling comparable object set with non-disjoint data%N")
189 create o.make (1)
190 obj_set1.put (o)
191 create o.make (3)
192 obj_set1.put (o)
193 create o.make (5)
194 obj_set1.put (o)
195 if obj_comparison then create o.make (5)end
196 obj_set2.put (o)
197 create o.make (2)
198 obj_set2.put (o)
199 create o.make (4)
200 obj_set2.put (o)
201 end
202 ensure
203 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
204 end
205
206 fill_string_sets (disjoint, obj_comparison: BOOLEAN) is
207 -- Fill string sets with (non-)disjoint data and set
208 -- `object_comparison' of the sets to `obj_comparison'.
209 require
210 sets_exist: string_set1 /= Void and string_set2 /= Void
211 local
212 s: STRING
213 do
214 if obj_comparison then
215 Io.put_string ("object comparison set%N")
216 string_set1.compare_objects
217 string_set2.compare_objects
218 else
219 Io.put_string ("reference comparison set%N")
220 string_set1.compare_references
221 string_set2.compare_references
222 end
223 if disjoint then
224 Io.put_string ("Filling string set with disjoint data%N")
225 string_set1.put ("foo")
226 string_set1.put ("bar")
227 string_set1.put ("boo")
228 string_set2.put ("bla")
229 string_set2.put ("baz")
230 string_set2.put ("bat")
231 else
232 Io.put_string ("Filling string set with non-disjoint data%N")
233 string_set1.put ("foo")
234 string_set1.put ("bar")
235 if obj_comparison then
236 string_set1.put ("boo")
237 string_set2.put ("boo")
238 else
239 s := "boo"
240 string_set1.put (s)
241 string_set2.put (s)
242 end
243 string_set2.put ("bla")
244 string_set2.put ("baz")
245 end
246 ensure
247 sets_filled: not string_set1.is_empty and not string_set2.is_empty
248 same_comparison: string_set1.object_comparison =
249 string_set2.object_comparison
250 end
251
252 check_obj_sets is
253 -- Process object sets.
254 require
255 sets_exist: obj_set1 /= Void and obj_set2 /= Void
256 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
257 do
258 Io.put_string ("object set disjoint: ")
259 Io.put_boolean (obj_set1.disjoint (obj_set2))
260 Io.put_new_line
261 end
262
263 check_string_sets is
264 -- Process string sets.
265 require
266 sets_exist: string_set1 /= Void and string_set2 /= Void
267 sets_filled: not string_set1.is_empty and not string_set2.is_empty
268 do
269 Io.put_string ("string set disjoint: ")
270 Io.put_boolean (string_set1.disjoint (string_set2))
271 Io.put_new_line
272 end
273
274 end -- class TEST
275
276

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23