def test_path(self): self.assertEqual(Path().to_s(), "") self.assertEqual(Path([ Command.parse("M150 0"), Command.parse("L75 200"), Command.parse("L225 200"), Command.parse("Z") ]).to_s(), "M150 0 L75 200 225 200 Z") # Parse self.assertEqual(Path.parse("M150 0 L75 200 L225 200 C100,100 250,100 250,200 Z").to_s(), "M150 0 L75 200 225 200 C100,100 250,100 250,200 Z") self.assertEqual(Path.parse("M150 0 L75 200 L225 200 C100,100 250,100 250,200 Z ").to_s(), "M150 0 L75 200 225 200 C100,100 250,100 250,200 Z") self.assertEqual(Path.parse("M150 0 L75 200 225 200 C100,100 250,100 250,200 Z").to_s(), "M150 0 L75 200 225 200 C100,100 250,100 250,200 Z") self.assertEqual(Path.parse("M150 0 L75,200 225,200 C-100 100 -250,100 250,200 Z").to_s(), "M150 0 L75 200 225 200 C-100,100 -250,100 250,200 Z")
def test_command(self): # moveto self.assertEqual(Command.parse("M150 0").to_s(), "M150 0") self.assertEqual(Command.parse("M 150 0").to_s(), "M150 0") self.assertEqual(Command.parse("M150 0.1").to_s(), "M150 0.1") self.assertEqual(Command.parse("m150 0").to_s(), "m150 0") # lineto self.assertEqual(Command.parse("L150 0").to_s(), "L150 0") self.assertEqual(Command.parse("l150.1 0").to_s(), "l150.1 0") # closepath self.assertEqual(Command.parse(" Z").to_s(), "Z") self.assertEqual(Command.parse("z").to_s(), "z") # curveto self.assertEqual(Command.parse("C100,100 250,100 250,200").to_s(), "C100,100 250,100 250,200") self.assertEqual(Command.parse("c100 100 250 100 250,200").to_s(), "c100,100 250,100 250,200")