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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.23