void TestApp::test_matrix_mat3() { Console::write_line(" Class: Mat3"); Console::write_line(" Function: inverse()"); { Mat3d test_src(2, 3, 4, 2, -5, 2, -3, 6, -3); Mat3d test_inv; Mat3d test_dest; Mat3d test_ident = Mat3d::identity(); test_dest = test_src; test_dest.inverse(); test_dest = test_dest * test_src; if (test_ident != test_dest) fail(); Mat4d test_4d(test_src); Mat3d test_3d(test_4d); if (test_3d != test_src) fail(); test_4d =test_src; test_3d =test_4d; if (test_3d != test_src) fail(); } Mat3i test_a(3, 1, 2, 4, 5 ,6, 4, 2, 1); Mat3i test_b(4, 7, 2, 5, 3, 5, 2, 9, 3); Console::write_line(" Function: multiply() and operator"); { Mat3i result = test_b * test_a; Mat3i answer(21, 42, 17, 53, 97, 51, 28, 43, 21); if (result != answer) fail(); result = Mat3i::multiply(test_b, test_a); if (result != answer) fail(); } Console::write_line(" Function: add() and operator"); { Mat3i result = test_a + test_b; if (result != Mat3i(7, 8, 4, 9, 8, 11, 6, 11, 4)) fail(); result = Mat3i::add(test_a, test_b); if (result != Mat3i(7, 8, 4, 9, 8, 11, 6, 11, 4)) fail(); } Console::write_line(" Function: subtract() and operator"); { Mat3i result = test_a - test_b; if (result != Mat3i(-1, -6, 0, -1, 2, 1, 2, -7, -2)) fail(); result = Mat3i::subtract(test_a, test_b); if (result != Mat3i(-1, -6, 0, -1, 2, 1, 2, -7, -2)) fail(); } }
int main(int argc, char* argv[]) try { typedef GIL::rgba8_view view_type; typedef GIL::image_factory_t<view_type> factory_type; typedef factory_type::image_format_type format_type; factory_type factory; boost::filesystem::path test_src(argc > 1 ? argv[1] : "", boost::filesystem::native); adobe::static_name_t targa_tag("targa"); GIL::rgba8_image image; adobe::dictionary_t params; assert (boost::filesystem::exists(test_src)); boost::filesystem::filebuf filebuf; filebuf.open(test_src, std::ios_base::in | std::ios_base::binary); factory.register_format(format_type(targa_tag, GIL::targa_t<view_type>())); assert (factory.is_registered(targa_tag)); assert (factory.read(image, filebuf, params) == targa_tag); #if 0 // no file format writing at this time GIL::any_view view(GIL::view(image)); factory.write(view, filebuf); #endif factory.unregister_format(targa_tag); assert (!factory.is_registered(targa_tag)); return 0; } catch (const std::exception& error) { std::cerr << "Exception: " << error.what() << std::endl; return 1; } catch (...) { std::cerr << "Exception: Unknown" << std::endl; return 1; }