svg-path-test.h revision 9eb886f0efdd076022ef171278e8475a580a1e91
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm // Lots of ways to define the same rectangle
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteClosed.push_back("M 1,2 L 4,2 L 4,8 L 1,8 L 1,2 Z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteClosed.push_back("M 1,2 L 4,2 L 4,8 L 1,8 z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteClosed.push_back("M 1,2 4,2 4,8 1,8 z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteClosed.push_back("M 1,2 H 4 V 8 H 1 z");
afb717c6e7d29c86c404b6627855c438d6dc2c0fjohanengelen rectanglesRelativeClosed.push_back("m 1,2 l 3,0 l 0,6 l -3,0 z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesRelativeClosed.push_back("m 1,2 3,0 0,6 -3,0 z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesRelativeClosed.push_back("m 1,2 h 3 v 6 h -3 z");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteOpen.push_back("M 1,2 L 4,2 L 4,8 L 1,8 L 1,2");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteOpen.push_back("M 1,2 4,2 4,8 1,8 1,2");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesAbsoluteOpen.push_back("M 1,2 H 4 V 8 H 1 V 2");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesRelativeOpen.push_back("m 1,2 l 3,0 l 0,6 l -3,0 l 0,-6");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm rectanglesRelativeOpen.push_back("m 1,2 3,0 0,6 -3,0 0,-6");
62d835b4bbb0f1f046e30d9b67f8e9517cc6175cjohanengelen rectanglesRelativeOpen.push_back("m 1,2 h 3 v 6 h -3 v -6");
c874d2ee5e49a890191f12deb8846ca099359e1ecilix // TODO: Also test some (smooth) cubic/quadratic beziers and elliptical arcs
bdd7add6c064afee52d2eabeaa18f745430e5a4djohanengelen// createSuite and destroySuite get us per-suite setup and teardown
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm// without us having to worry about static initialization order, etc.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm static SvgPathTest *createSuite() { return new SvgPathTest(); }
c776c7f3860f657ea9db62d62e9da98df09b0c70johanengelen static void destroySuite( SvgPathTest *suite ) { delete suite; }
390745fa4524b55aad12d5d2d656cd73e75a0bc0cilix for(size_t i=0; i<rectanglesAbsoluteClosed.size(); i++) {
afb717c6e7d29c86c404b6627855c438d6dc2c0fjohanengelen NArtBpath * bpath = sp_svg_read_path(rectanglesAbsoluteClosed[i].c_str());
43f848b15ee40a6c108ae9d965cf06f055ecb7a5johanengelen for(size_t i=0; i<rectanglesRelativeClosed.size(); i++) {
43f848b15ee40a6c108ae9d965cf06f055ecb7a5johanengelen NArtBpath * bpath = sp_svg_read_path(rectanglesRelativeClosed[i].c_str());
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm for(size_t i=0; i<rectanglesAbsoluteOpen.size(); i++) {
539b02bd98b6985f91ccbf7041f88fdf93061531johanengelen NArtBpath * bpath = sp_svg_read_path(rectanglesAbsoluteOpen[i].c_str());
afb717c6e7d29c86c404b6627855c438d6dc2c0fjohanengelen for(size_t i=0; i<rectanglesRelativeOpen.size(); i++) {
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm NArtBpath * bpath = sp_svg_read_path(rectanglesRelativeOpen[i].c_str());
std::string path_str = rectanglesAbsoluteClosed[0] + rectanglesRelativeOpen[0] + rectanglesRelativeClosed[0] + rectanglesAbsoluteOpen[0];
void testReadZeroLengthSubpaths() {
void testReadImplicitMoveto() {
void testReadFloatingPoint() {
void testReadImplicitSeparation() {
void testReadErrorMisplacedCharacter() {
char const * path_str;
void testReadErrorUnrecognizedCharacter() {
char const * path_str;
void testReadErrorTypo() {
char const * path_str;
void testReadErrorIllformedNumbers() {
char const * path_str;
void testReadErrorJunk() {
char const * path_str;
path_str = "M 1,2 4,2 4,8 1,8 z j 357 hkjh.,34e34 90ih6kj4 h5k6vlh4N.,6,45wikuyi3yere..3487 m 13,23";
void testReadErrorStopReading() {
char const * path_str;
void testRoundTrip() {
// This is the easiest way to (also) test writing path data, as a path can be written in more than one way.
char * path_str;
bpath = sp_svg_read_path((rectanglesAbsoluteClosed[0] + rectanglesRelativeOpen[0] + rectanglesRelativeClosed[0] + rectanglesAbsoluteOpen[0]).c_str());
bpath = sp_svg_read_path("M .01,.02 L 0.04,0.02 L.04,.08L0.01,0.08 z""M 1e-2,.2e-1 L 0.004e1,0.0002e+2 L04E-2,.08e0L1.0e-2,80e-3 z");
void testMinexpPrecision() {
char * path_str;
bpath = sp_svg_read_path("M 123456781,1.23456781e-8 L 123456782,1.23456782e-8 L 123456785,1.23456785e-8 L 10123456400,1.23456785e-8 L 123456789,1.23456789e-8 L 123456789,101.234564e-8 L 123456789,1.23456789e-8");
TS_ASSERT_RELATION( streq_rel , "m 123456780,1.2345678e-8 0,0 10,1e-15 9999999210,0 -9999999210,0 0,9.99999921e-7 0,-9.99999921e-7" , path_str );
switch(a->code) {
case NR_MOVETO:
case NR_MOVETO_OPEN:
case NR_LINETO:
case NR_CURVETO: