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

Contents of /trunk/eweasel/tests/set002/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: 6060 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)
17 process_obj_sets
18 create_obj_sets
19 fill_obj_sets (True)
20 process_obj_sets
21 create_obj_cmp_sets
22 fill_obj_cmp_sets (False)
23 process_obj_sets
24 create_obj_cmp_sets
25 fill_obj_cmp_sets (True)
26 process_obj_sets
27 from
28 i := 1
29 until
30 i > Implementations
31 loop
32 create_string_sets (i)
33 fill_string_sets (False)
34 process_string_sets
35 create_string_sets (i)
36 fill_string_sets (True)
37 process_string_sets
38 i := i + 1
39 end
40 end
41
42 feature {NONE} -- Constants
43
44 Implementations: INTEGER is 2
45 -- Number of implementations
46
47
48 feature {NONE} -- Implementation
49
50 obj_set1, obj_set2: TRAVERSABLE_SUBSET [SAMPLE_OBJECT]
51
52 string_set1, string_set2: TRAVERSABLE_SUBSET [STRING]
53
54 create_obj_sets is
55 -- Create object sets.
56 do
57 Io.put_string ("Create object set as type LINKED_SET%N")
58 create {LINKED_SET [SAMPLE_OBJECT]} obj_set1.make
59 create {LINKED_SET [SAMPLE_OBJECT]} obj_set2.make
60 end
61
62 create_obj_cmp_sets is
63 -- Create comparable object sets.
64 do
65 Io.put_string ("Create comparable object set as type BINARY_SEARCH_TREE_SET%N")
66 create {BINARY_SEARCH_TREE_SET [SAMPLE_OBJECT_COMPARABLE]} obj_set1.make
67 create {BINARY_SEARCH_TREE_SET [SAMPLE_OBJECT_COMPARABLE]} obj_set2.make
68 end
69
70 create_string_sets (impl: INTEGER) is
71 -- Create string sets using the implementation determined by
72 -- `impl'.
73 require
74 defined_implementation: 1 <= impl and impl <= Implementations
75 do
76 inspect
77 impl
78 when 1 then
79 Io.put_string ("Create string set as type LINKED_SET%N")
80 create {LINKED_SET [STRING]} string_set1.make
81 create {LINKED_SET [STRING]} string_set2.make
82 when 2 then
83 Io.put_string ("Create string set as type BINARY_SEARCH_TREE_SET%N")
84 create {BINARY_SEARCH_TREE_SET [STRING]} string_set1.make
85 create {BINARY_SEARCH_TREE_SET [STRING]} string_set2.make
86 end
87 end
88
89 fill_obj_sets (obj_comparison: BOOLEAN) is
90 -- Fill object sets and set `object_comparison' of the sets to
91 -- `obj_comparison'.
92 require
93 sets_exist: obj_set1 /= Void and obj_set2 /= Void
94 local
95 o: SAMPLE_OBJECT
96 do
97 if obj_comparison then
98 Io.put_string ("object comparison set%N")
99 obj_set1.compare_objects
100 obj_set2.compare_objects
101 else
102 Io.put_string ("reference comparison set%N")
103 obj_set1.compare_references
104 obj_set2.compare_references
105 end
106 Io.put_string ("Filling object set%N")
107 create o.make (1)
108 obj_set1.put (o)
109 create o.make (3)
110 obj_set1.put (o)
111 create o.make (5)
112 obj_set1.put (o)
113 if obj_comparison then create o.make (5) end
114 obj_set2.put (o)
115 create o.make (2)
116 obj_set2.put (o)
117 create o.make (4)
118 obj_set2.put (o)
119 ensure
120 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
121 end
122
123 fill_obj_cmp_sets (obj_comparison: BOOLEAN) is
124 -- Fill object sets and set `object_comparison' of the sets to
125 -- `obj_comparison'.
126 require
127 sets_exist: obj_set1 /= Void and obj_set2 /= Void
128 local
129 o: SAMPLE_OBJECT_COMPARABLE
130 do
131 if obj_comparison then
132 Io.put_string ("object comparison set%N")
133 obj_set1.compare_objects
134 obj_set2.compare_objects
135 else
136 Io.put_string ("reference comparison set%N")
137 obj_set1.compare_references
138 obj_set2.compare_references
139 end
140 Io.put_string ("Filling comparable object set%N")
141 create o.make (1)
142 obj_set1.put (o)
143 create o.make (3)
144 obj_set1.put (o)
145 create o.make (5)
146 obj_set1.put (o)
147 if obj_comparison then create o.make (5) end
148 obj_set2.put (o)
149 create o.make (2)
150 obj_set2.put (o)
151 create o.make (4)
152 obj_set2.put (o)
153 ensure
154 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
155 end
156
157 fill_string_sets (obj_comparison: BOOLEAN) is
158 -- Fill string sets and set `object_comparison' of the sets to
159 -- `obj_comparison'.
160 require
161 sets_exist: string_set1 /= Void and string_set2 /= Void
162 local
163 s: STRING
164 do
165 if obj_comparison then
166 Io.put_string ("object comparison set%N")
167 string_set1.compare_objects
168 string_set2.compare_objects
169 else
170 Io.put_string ("reference comparison set%N")
171 string_set1.compare_references
172 string_set2.compare_references
173 end
174 Io.put_string ("Filling string set%N")
175 string_set1.put ("foo")
176 string_set1.put ("bar")
177 if obj_comparison then
178 string_set1.put ("boo")
179 string_set2.put ("boo")
180 else
181 s := "boo"
182 string_set1.put (s)
183 string_set2.put (s)
184 end
185 string_set2.put ("bla")
186 string_set2.put ("baz")
187 ensure
188 sets_filled: not string_set1.is_empty and not string_set2.is_empty
189 same_comparison: string_set1.object_comparison =
190 string_set2.object_comparison
191 end
192
193 process_obj_sets is
194 -- Process object sets.
195 require
196 sets_exist: obj_set1 /= Void and obj_set2 /= Void
197 sets_filled: not obj_set1.is_empty and not obj_set2.is_empty
198 do
199 obj_set1.symdif (obj_set2)
200 Io.put_string ("Set 1: ")
201 from obj_set1.start until obj_set1.after loop
202 Io.put_integer (obj_set1.item.item)
203 Io.put_string (", ")
204 obj_set1.forth
205 end
206 Io.put_new_line
207 Io.put_string ("Set 2: ")
208 from obj_set2.start until obj_set2.after loop
209 Io.put_integer (obj_set2.item.item)
210 Io.put_string (", ")
211 obj_set2.forth
212 end
213 Io.put_new_line
214 end
215
216 process_string_sets is
217 -- Process string sets.
218 require
219 sets_exist: string_set1 /= Void and string_set2 /= Void
220 sets_filled: not string_set1.is_empty and not string_set2.is_empty
221 do
222 string_set1.symdif (string_set2)
223 Io.put_string ("Set 1: ")
224 from string_set1.start until string_set1.after loop
225 Io.put_string (string_set1.item)
226 Io.put_string (", ")
227 string_set1.forth
228 end
229 Io.put_new_line
230 Io.put_string ("Set 2: ")
231 from string_set2.start until string_set2.after loop
232 Io.put_string (string_set2.item)
233 Io.put_string (", ")
234 string_set2.forth
235 end
236 Io.put_new_line
237 end
238
239 end -- class TEST
240
241

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23