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

Function testC4

src/python/PyImathTest/main.cpp:992–1148  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

990
991
992void
993testC4 ()
994{
995 object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__")))));
996 object mainNamespace = mainModule.attr ("__dict__");
997
998 std::cerr << "Testing C4*:\n";
999
1000 std::string code =
1001 "from imath import *\n"
1002 "c4c = Color4c (1, 2, 3, 4)\n"
1003 "c4f = Color4f (1.1, 2.2, 3.3, 4.4)\n"
1004 "t4c = (5, 6, 7, 8)\n"
1005 "t4f = (5.5, 6.6, 7.7, 8.8)\n"
1006 "l4c = [9, 10, 11, 12]\n"
1007 "l4f = [13.13, 14.14, 15.15, 16.16]\n"
1008 "i = 1\n"
1009 "from wrap import *\n"
1010 "w = wrap ('Color4c')\n"
1011 "assert w == Color4c (1, 2, 3, 4)\n"
1012 "w = wrap ('Color4f')\n"
1013 "assert equal (w[0], 1.1, 1e-7)\n"
1014 "assert equal (w[1], 2.2, 1e-7)\n"
1015 "assert equal (w[2], 3.3, 1e-7)\n"
1016 "assert equal (w[3], 4.4, 1e-7)\n";
1017
1018 handle<> ignored (PyRun_String (code.c_str(), Py_file_input,
1019 mainNamespace.ptr(), mainNamespace.ptr()));
1020
1021 //
1022
1023 extract <object> ec4c (mainNamespace ["c4c"]);
1024 assert (ec4c.check());
1025
1026 PyObject *c4cObj = ec4c().ptr();
1027 assert (c4cObj != 0);
1028
1029 extract <object> ec4f (mainNamespace ["c4f"]);
1030 assert (ec4f.check());
1031
1032 PyObject *c4fObj = ec4f().ptr();
1033 assert (c4fObj != 0);
1034
1035 extract <object> et4c (mainNamespace ["t4c"]);
1036 assert (et4c.check());
1037
1038 PyObject *t4cObj = et4c().ptr();
1039 assert (t4cObj != 0);
1040
1041 extract <object> et4f (mainNamespace ["t4f"]);
1042 assert (et4f.check());
1043
1044 PyObject *t4fObj = et4f().ptr();
1045 assert (t4fObj != 0);
1046
1047 extract <object> el4c (mainNamespace ["l4c"]);
1048 assert (el4c.check());
1049

Callers

nothing calls this directly

Calls 1

equalWithAbsErrorFunction · 0.70

Tested by

no test coverage detected