svg-affine-test.h revision 39a897cf2c4e5c0208d081fe7d51dc893b5c33d1
#include <cxxtest/TestSuite.h>
#include "streq.h"
#include <algorithm>
#include <glib.h>
#include <iostream>
#include <math.h>
#include <utility>
{
struct test_t {
char const * str;
};
struct approx_equal_pred {
{
double maxabsdiff = 0;
for(size_t i=0; i<6; i++) {
}
return maxabsdiff < 1e-14;
}
};
static char const * const read_fail_tests[25];
SvgAffineTest() {
}
// createSuite and destroySuite get us per-suite setup and teardown
// without us having to worry about static initialization order, etc.
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)"};
for(size_t i=0; i<n; i++) {
}
}
void testWriteIdentity()
{
}
void testReadMatrix()
{
TSM_ASSERT_RELATION(read_matrix_tests[i].str , approx_equal_pred , read_matrix_tests[i].matrix , cm);
}
}
void testReadTranslate()
{
TSM_ASSERT_RELATION(read_translate_tests[i].str , approx_equal_pred , read_translate_tests[i].matrix , cm);
}
}
void testReadScale()
{
}
}
void testReadRotate()
{
TSM_ASSERT_RELATION(read_rotate_tests[i].str , approx_equal_pred , read_rotate_tests[i].matrix , cm);
}
}
void testReadSkew()
{
}
}
void testWriteMatrix()
{
}
}
void testWriteTranslate()
{
}
}
void testWriteScale()
{
}
}
void testWriteRotate()
{
}
}
void testWriteSkew()
{
}
}
void testReadConcatenation()
{
// NOTE: According to the SVG specification (see the syntax at http://www.w3.org/TR/SVG/coords.html#TransformAttribute
// there should be 1 or more comma-wsp sequences between transforms... This doesn't make sense and it seems
// likely that instead of a + they meant a ? (zero or one comma-wsp sequences).
char const * str = "skewY(17)skewX(9)translate(7,13)scale(2)rotate(13)translate(3,5)";
Geom::Affine ref(2.0199976232558053, 1.0674773585906016, -0.14125199392774669, 1.9055550612095459, 14.412730624347654, 28.499820929377454); // Precomputed using Mathematica
}
void testReadFailures()
{
}
}
};
{"rotate(-13)",Geom::Affine(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),0,0)},
{"rotate(13,7,11)",Geom::Affine(cos(13.*DEGREE),sin(13.*DEGREE),-sin(13.*DEGREE),cos(13.*DEGREE),(1-cos(13.*DEGREE))*7+sin(13.*DEGREE)*11,(1-cos(13.*DEGREE))*11-sin(13.*DEGREE)*7)}};
"matrix((1,2,3,4,5,6)",
"matrix((1,2,3,4,5,6))",
"matrix(1,2,3,4,5,6))",
"matrix(,1,2,3,4,5,6)",
"matrix(1,2,3,4,5,6,)",
"matrix(1,2,3,4,5,)",
"matrix(1,2,3,4,5)",
"matrix(1,2,3,4,5e6-3)", // Here numbers HAVE to be separated by a comma-wsp sequence
"matrix(1,2,3,4,5e6.3)", // Here numbers HAVE to be separated by a comma-wsp sequence
"translate()",
"translate(,)",
"translate(1,)",
"translate(1,6,)",
"translate(1,6,0)",
"scale()",
"scale(1,6,2)",
"rotate()",
"rotate(1,6)",
"rotate(1,6,)",
"rotate(1,6,3,4)",
"skewX()",
"skewX(-)",
"skewX(.)",
"skewY(,)",
"skewY(1,2)"};
{"rotate(-13,7,11)",Geom::Affine(cos(-13.*DEGREE),sin(-13.*DEGREE),-sin(-13.*DEGREE),cos(-13.*DEGREE),(1-cos(-13.*DEGREE))*7+sin(-13.*DEGREE)*11,(1-cos(-13.*DEGREE))*11-sin(-13.*DEGREE)*7)}};
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :