// SPDX-License-Identifier: GPL-2.0-or-later /** @file * TODO: insert short description here *//* * Authors: see git history * * Copyright (C) 2017 Authors * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #include #include "svg/svg.h" #include "streq.h" #include <2geom/affine.h> #include #include #include #include #include class SvgAffineTest : public CxxTest::TestSuite { private: struct test_t { char const * str; Geom::Affine matrix; }; struct approx_equal_pred { bool operator()(Geom::Affine const &ref, Geom::Affine const &cm) const { double maxabsdiff = 0; for(size_t i=0; i<6; i++) { maxabsdiff = std::max(std::abs(ref[i]-cm[i]), maxabsdiff); } return maxabsdiff < 1e-14; } }; static test_t const read_matrix_tests[3]; static test_t const read_translate_tests[3]; static test_t const read_scale_tests[3]; static test_t const read_rotate_tests[4]; static test_t const read_skew_tests[3]; static char const * const read_fail_tests[25]; static test_t const write_matrix_tests[2]; static test_t const write_translate_tests[3]; static test_t const write_scale_tests[3]; static test_t const write_rotate_tests[3]; static test_t const write_skew_tests[3]; public: SvgAffineTest() { } // createSuite and destroySuite get us per-suite setup and teardown // without us having to worry about static initialization order, etc. static SvgAffineTest *createSuite() { return new SvgAffineTest(); } static void destroySuite( SvgAffineTest *suite ) { delete suite; } void testReadIdentity() { char const* strs[] = { //0, "", "matrix(1,0,0,1,0,0)", "translate(0,0)", "scale(1,1)", "rotate(0,0,0)", "skewX(0)", "skewY(0)"}; size_t n = G_N_ELEMENTS(strs); for(size_t i=0; i