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

Function testV2

src/python/PyImathTest/main.cpp:2058–2190  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2056
2057
2058void
2059testV2 ()
2060{
2061 object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__")))));
2062 object mainNamespace = mainModule.attr ("__dict__");
2063
2064 std::cerr << "Testing V2*:\n";
2065
2066 std::string code =
2067 "from imath import *\n"
2068 "v2i = V2i (1, 2)\n"
2069 "v2f = V2f (3.3, 4.4)\n"
2070 "v2d = V2d (5.5, 6.6)\n"
2071 "t = (7, 8)\n"
2072 "i = 1\n"
2073 "from wrap import *\n"
2074 "w = wrap ('V2i')\n"
2075 "assert w == V2i (1, 2)\n"
2076 "w = wrap ('V2f')\n"
2077 "assert w.equalWithAbsError (V2f (1.1, 2.2), 1e-7)\n"
2078 "w = wrap ('V2d')\n"
2079 "assert w.equalWithAbsError (V2d (1.1, 2.2), 1e-7)\n";
2080
2081 handle<> ignored (PyRun_String (code.c_str(), Py_file_input,
2082 mainNamespace.ptr(), mainNamespace.ptr()));
2083
2084 //
2085
2086 extract <object> ev2i (mainNamespace ["v2i"]);
2087 assert (ev2i.check());
2088
2089 PyObject *v2iObj = ev2i().ptr();
2090 assert (v2iObj != 0);
2091
2092 extract <object> ev2f (mainNamespace ["v2f"]);
2093 assert (ev2f.check());
2094
2095 PyObject *v2fObj = ev2f().ptr();
2096 assert (v2fObj != 0);
2097
2098 extract <object> ev2d (mainNamespace ["v2d"]);
2099 assert (ev2d.check());
2100
2101 PyObject *v2dObj = ev2d().ptr();
2102 assert (v2dObj != 0);
2103
2104 extract <object> et (mainNamespace["t"]);
2105 assert (et.check());
2106
2107 PyObject *tObj = et().ptr();
2108 assert (tObj != 0);
2109
2110 extract <object> ei (mainNamespace["i"]);
2111 assert (ei.check());
2112
2113 PyObject *iObj = ei().ptr();
2114 assert (iObj != 0);
2115

Callers

nothing calls this directly

Calls 1

equalWithAbsErrorMethod · 0.80

Tested by

no test coverage detected