| 2191 | |
| 2192 | |
| 2193 | void |
| 2194 | testV3 () |
| 2195 | { |
| 2196 | object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__"))))); |
| 2197 | object mainNamespace = mainModule.attr ("__dict__"); |
| 2198 | |
| 2199 | std::cerr << "Testing V3*:\n"; |
| 2200 | |
| 2201 | std::string code = |
| 2202 | "from imath import *\n" |
| 2203 | "v3i = V3i (1, 2, 3)\n" |
| 2204 | "v3f = V3f (4.4, 5.5, 6.6)\n" |
| 2205 | "v3d = V3d (7.7, 8.8, 9.9)\n" |
| 2206 | "t = (10, 11, 12)\n" |
| 2207 | "i = 1\n" |
| 2208 | "from wrap import *\n" |
| 2209 | "w = wrap ('V3i')\n" |
| 2210 | "assert w == V3i (1, 2, 3)\n" |
| 2211 | "w = wrap ('V3f')\n" |
| 2212 | "assert w.equalWithAbsError (V3f (1.1, 2.2, 3.3), 1e-7)\n" |
| 2213 | "w = wrap ('V3d')\n" |
| 2214 | "assert w.equalWithAbsError (V3d (1.1, 2.2, 3.3), 1e-7)\n"; |
| 2215 | |
| 2216 | handle<> ignored (PyRun_String (code.c_str(), Py_file_input, |
| 2217 | mainNamespace.ptr(), mainNamespace.ptr())); |
| 2218 | |
| 2219 | // |
| 2220 | |
| 2221 | extract <object> ev3i (mainNamespace ["v3i"]); |
| 2222 | assert (ev3i.check()); |
| 2223 | |
| 2224 | PyObject *v3iObj = ev3i().ptr(); |
| 2225 | assert (v3iObj != 0); |
| 2226 | |
| 2227 | extract <object> ev3f (mainNamespace ["v3f"]); |
| 2228 | assert (ev3f.check()); |
| 2229 | |
| 2230 | PyObject *v3fObj = ev3f().ptr(); |
| 2231 | assert (v3fObj != 0); |
| 2232 | |
| 2233 | extract <object> ev3d (mainNamespace ["v3d"]); |
| 2234 | assert (ev3d.check()); |
| 2235 | |
| 2236 | PyObject *v3dObj = ev3d().ptr(); |
| 2237 | assert (v3dObj != 0); |
| 2238 | |
| 2239 | extract <object> et (mainNamespace["t"]); |
| 2240 | assert (et.check()); |
| 2241 | |
| 2242 | PyObject *tObj = et().ptr(); |
| 2243 | assert (tObj != 0); |
| 2244 | |
| 2245 | extract <object> ei (mainNamespace["i"]); |
| 2246 | assert (ei.check()); |
| 2247 | |
| 2248 | PyObject *iObj = ei().ptr(); |
| 2249 | assert (iObj != 0); |
| 2250 |
nothing calls this directly
no test coverage detected