%description: Test cPathFigure's path parsing %global: static bool equalIgnoringSpaces(const char *s1, const char *s2) { do { while (*s1 == ' ') s1++; while (*s2 == ' ') s2++; if (*s1 != *s2) return false; s1++; s2++; } while (*s1 && *s2); return true; } static void testPath(cPathFigure *f, const char *path) { try { f->setPath(path); const char *newPath = f->getPath(); EV << newPath; if (!equalIgnoringSpaces(path, newPath)) EV << " ==> DIFFERS!\n"; EV << "\n"; } catch(std::exception& e) { EV << path << " ==> ERROR: " << e.what() << "\n"; } } %activity: cPathFigure *f = new cPathFigure(); #define T(path) testPath(f,path) // spaces T("M 1 2 Z"); T("M -1 -2 Z"); T("M1.5 2.5Z"); T("M-1.5 -2.5Z"); // primitives T("M 1 2 Z"); T("m 3 4 Z"); T("L 5 6 Z"); T("l 7 8 Z"); T("H 10 Z"); T("h 20 Z"); T("V 30 Z"); T("v 40 Z"); T("A 10 15 45 0 0 100 200 Z"); T("a 10 15 45 0 0 100 200 Z"); T("Q 50 60 100 200 Z"); T("q 50 60 100 200 Z"); T("T 100 200 Z"); T("t 100 200 Z"); T("C 20 30 50 60 100 200 Z"); T("c 20 30 50 60 100 200 Z"); T("S 50 60 100 200 Z"); T("s 50 60 100 200 Z"); // errors T("M 1 2 F"); T("M 1 Z"); T("A 10 15 45 0 999 100 200 Z"); delete f; EV << ".\n"; %contains: stdout M 1 2 Z M -1 -2 Z M 1.5 2.5 Z M -1.5 -2.5 Z M 1 2 Z m 3 4 Z L 5 6 Z l 7 8 Z H 10 Z h 20 Z V 30 Z v 40 Z A 10 15 45 0 0 100 200 Z a 10 15 45 0 0 100 200 Z Q 50 60 100 200 Z q 50 60 100 200 Z T 100 200 Z t 100 200 Z C 20 30 50 60 100 200 Z c 20 30 50 60 100 200 Z S 50 60 100 200 Z s 50 60 100 200 Z M 1 2 F ==> ERROR: Unknown drawing primitive 'F' in path near column 7 M 1 Z ==> ERROR: Number expected in path near column 3 A 10 15 45 0 999 100 200 Z ==> ERROR: Boolean (0 or 1) expected in path near column 16 .