MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/Imath / testBox2

Function testBox2

src/python/PyImathTest/main.cpp:202–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

200
201
202void
203testBox2 ()
204{
205 object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__")))));
206 object mainNamespace = mainModule.attr ("__dict__");
207
208 std::cerr << "Testing Box2*:\n";
209
210 std::string code =
211 "from imath import *\n"
212 "b2i = Box2i ((1, 2), (3, 4))\n"
213 "b2f = Box2f ((5.5, 6.6), (7.7, 8.8))\n"
214 "b2d = Box2d ((9.9, 10.10), (11.11, 12.12))\n"
215 "t2i = ((1, 2), (3, 4))\n"
216 "t2V2i = (V2i (1, 2), V2i (3, 4))\n"
217 "t2iMix = (V2i (1, 2), (3, 4))\n"
218 "t2f = ((5.5, 6.6), (7.7, 8.8))\n"
219 "t2V2f = (V2f (5.5, 6.6), V2f (7.7, 8.8))\n"
220 "t2fMix = (V2f (5.5, 6.6), (7.7, 8.8))\n"
221 "t2V2d = (V2d (9.9, 10.10), V2d (11.11, 12.12))\n"
222 "t2dMix = (V2d (9.9, 10.10), (11.11, 12.12))\n"
223 "i = 1\n"
224 "from wrap import *\n"
225 "w = wrap ('Box2i')\n"
226 "assert w == Box2i ((1, 2), (3, 4))\n"
227 "w = wrap ('Box2f')\n"
228 "assert w.min().equalWithAbsError ((1.1, 2.2), 1e-7)\n"
229 "assert w.max().equalWithAbsError ((3.3, 4.4), 1e-7)\n"
230 "w = wrap ('Box2d')\n"
231 "assert w.min().equalWithAbsError ((1.1, 2.2), 1e-7)\n"
232 "assert w.max().equalWithAbsError ((3.3, 4.4), 1e-7)\n";
233
234 handle<> ignored (PyRun_String (code.c_str(), Py_file_input,
235 mainNamespace.ptr(), mainNamespace.ptr()));
236 //
237
238 extract <object> eb2i (mainNamespace ["b2i"]);
239 assert (eb2i.check());
240
241 PyObject *b2iObj = eb2i().ptr();
242 assert (b2iObj != 0);
243
244 extract <object> eb2f (mainNamespace ["b2f"]);
245 assert (eb2f.check());
246
247 PyObject *b2fObj = eb2f().ptr();
248 assert (b2fObj != 0);
249
250 extract <object> eb2d (mainNamespace ["b2d"]);
251 assert (eb2d.check());
252
253 PyObject *b2dObj = eb2d().ptr();
254 assert (b2dObj != 0);
255
256 extract <object> et2i (mainNamespace["t2i"]);
257 assert (et2i.check());
258
259 PyObject *t2iObj = et2i().ptr();

Callers

nothing calls this directly

Calls 1

equalWithAbsErrorMethod · 0.80

Tested by

no test coverage detected