| 1241 | |
| 1242 | |
| 1243 | void |
| 1244 | testFrustum () |
| 1245 | { |
| 1246 | object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__"))))); |
| 1247 | object mainNamespace = mainModule.attr ("__dict__"); |
| 1248 | |
| 1249 | std::cerr << "Testing Frustum*:\n"; |
| 1250 | |
| 1251 | std::string code = |
| 1252 | "from imath import *\n" |
| 1253 | "ff = Frustumf (-1.0, -100.0, -2.0, 2.0, 3.0, -3.0, 0)\n" |
| 1254 | "fd = Frustumf (-2.0, -50.0, -3.0, 3.0, 2.0, -2.0, 1)\n" |
| 1255 | "i = 1\n" |
| 1256 | "from wrap import *\n" |
| 1257 | "w = wrap ('Frustumf')\n" |
| 1258 | "assert equal (w.nearPlane(), 1.1, 1e-7)\n" |
| 1259 | "assert equal (w.farPlane(), 2.2, 1e-7)\n" |
| 1260 | "assert equal (w.left(), 3.3, 1e-7)\n" |
| 1261 | "assert equal (w.right(), 4.4, 1e-7)\n" |
| 1262 | "assert equal (w.top(), 5.5, 1e-7)\n" |
| 1263 | "assert equal (w.bottom(), 6.6, 1e-7)\n" |
| 1264 | "assert w.orthographic() == 0\n" |
| 1265 | "w = wrap ('Frustumd')\n" |
| 1266 | "assert equal (w.nearPlane(), 1.1, 1e-6)\n" |
| 1267 | "assert equal (w.farPlane(), 2.2, 1e-7)\n" |
| 1268 | "assert equal (w.left(), 3.3, 1e-7)\n" |
| 1269 | "assert equal (w.right(), 4.4, 1e-7)\n" |
| 1270 | "assert equal (w.top(), 5.5, 1e-7)\n" |
| 1271 | "assert equal (w.bottom(), 6.6, 1e-7)\n" |
| 1272 | "assert w.orthographic() == 0\n"; |
| 1273 | |
| 1274 | handle<> ignored (PyRun_String (code.c_str(), Py_file_input, |
| 1275 | mainNamespace.ptr(), mainNamespace.ptr())); |
| 1276 | |
| 1277 | // |
| 1278 | |
| 1279 | extract <object> eff (mainNamespace["ff"]); |
| 1280 | assert (eff.check()); |
| 1281 | |
| 1282 | PyObject *ffObj = eff().ptr(); |
| 1283 | assert (ffObj != 0); |
| 1284 | |
| 1285 | extract <object> efd (mainNamespace["fd"]); |
| 1286 | assert (efd.check()); |
| 1287 | |
| 1288 | PyObject *fdObj = efd().ptr(); |
| 1289 | assert (fdObj != 0); |
| 1290 | |
| 1291 | extract <object> ei (mainNamespace["i"]); |
| 1292 | assert (ei.check()); |
| 1293 | |
| 1294 | PyObject *iObj = ei().ptr(); |
| 1295 | assert (iObj != 0); |
| 1296 | |
| 1297 | // |
| 1298 | |
| 1299 | std::cerr << "Testing Frustumf:\n"; |
| 1300 |
nothing calls this directly
no test coverage detected