MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / testAddRemoveClear

Method testAddRemoveClear

test/tests/containers/TestSet.h:148–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 }
147
148 void testAddRemoveClear() {
149
150 // ----- Test add() ----- //
151
152 Set<int> set1(mAllocator);
153 bool add1 = set1.add(10);
154 bool add2 = set1.add(80);
155 bool add3 = set1.add(130);
156 rp3d_test(add1);
157 rp3d_test(add2);
158 rp3d_test(add3);
159 rp3d_test(set1.contains(10));
160 rp3d_test(set1.contains(80));
161 rp3d_test(set1.contains(130));
162 rp3d_test(set1.size() == 3);
163
164 bool add4 = set1.add(80);
165 rp3d_test(!add4);
166 rp3d_test(set1.contains(80));
167 rp3d_test(set1.size() == 3);
168
169 Set<int> set2(mAllocator, 15);
170 for (int i = 0; i < 1000000; i++) {
171 set2.add(i);
172 }
173 bool isValid = true;
174 for (int i = 0; i < 1000000; i++) {
175 if (!set2.contains(i)) isValid = false;
176 }
177 rp3d_test(isValid);
178
179 set1.remove(10);
180 bool add = set1.add(10);
181 rp3d_test(add);
182 rp3d_test(set1.size() == 3);
183 rp3d_test(set1.contains(10));
184
185 set1.add(34);
186 rp3d_test(set1.contains(34));
187 rp3d_test(set1.size() == 4);
188
189 // ----- Test remove() ----- //
190
191 set1.remove(10);
192 rp3d_test(!set1.contains(10));
193 rp3d_test(set1.contains(80));
194 rp3d_test(set1.contains(130));
195 rp3d_test(set1.contains(34));
196 rp3d_test(set1.size() == 3);
197
198 set1.remove(80);
199 rp3d_test(!set1.contains(80));
200 rp3d_test(set1.contains(130));
201 rp3d_test(set1.contains(34));
202 rp3d_test(set1.size() == 2);
203
204 set1.remove(130);
205 rp3d_test(!set1.contains(130));

Callers

nothing calls this directly

Calls 8

TestValueSetClass · 0.85
addMethod · 0.45
containsMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected