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

Function testQuat

src/python/PyImathTest/main.cpp:1753–1851  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1751
1752
1753void
1754testQuat ()
1755{
1756 object mainModule ((handle<> (borrowed (PyImport_AddModule ("__main__")))));
1757 object mainNamespace = mainModule.attr ("__dict__");
1758
1759 std::cerr << "Testing Quat*:\n";
1760
1761 std::string code =
1762 "from imath import *\n"
1763 "qf = Quatf (1.1, 2.2, 3.3, 4.4)\n"
1764 "qd = Quatd (5.5, V3d (6.6, 7.7, 8.8))\n"
1765 "t = (9.9, 10.10, 11.11, 12.12)\n"
1766 "i = 1\n"
1767 "from wrap import *\n"
1768 "w = wrap ('Quatf')\n"
1769 "assert equal (w.r(), 1.1, 1e-7)\n"
1770 "assert w.v().equalWithAbsError (V3f (2.2, 3.3, 4.4), 1e-7)\n"
1771 "w = wrap ('Quatd')\n"
1772 "assert equal (w.r(), 1.1, 1e-7)\n"
1773 "assert w.v().equalWithAbsError (V3d (2.2, 3.3, 4.4), 1e-7)\n";
1774
1775 handle<> ignored (PyRun_String (code.c_str(), Py_file_input,
1776 mainNamespace.ptr(), mainNamespace.ptr()));
1777
1778 //
1779
1780 extract <object> eqf (mainNamespace["qf"]);
1781 assert (eqf.check());
1782
1783 PyObject *qfObj = eqf().ptr();
1784 assert (qfObj != 0);
1785
1786 extract <object> eqd (mainNamespace["qd"]);
1787 assert (eqd.check());
1788
1789 PyObject *qdObj = eqd().ptr();
1790 assert (qdObj != 0);
1791
1792 extract <object> et (mainNamespace["t"]);
1793 assert (et.check());
1794
1795 PyObject *tObj = et().ptr();
1796 assert (tObj != 0);
1797
1798 extract <object> ei (mainNamespace["i"]);
1799 assert (ei.check());
1800
1801 PyObject *iObj = ei().ptr();
1802 assert (iObj != 0);
1803
1804 //
1805
1806 std::cerr << "Testing Quatf:\n";
1807
1808 IMATH_NAMESPACE::Quatf qfAsQf;
1809 assert (PyImath::Quatf::convert (qfObj, &qfAsQf) == 1);
1810 assert (IMATH_NAMESPACE::equalWithAbsError (qfAsQf.r, 1.1f, 1e-7f));

Callers

nothing calls this directly

Calls 2

equalWithAbsErrorMethod · 0.80
equalWithAbsErrorFunction · 0.70

Tested by

no test coverage detected