Use decimals for path data and limit to 6 digits of precision

This commit is contained in:
JSCHILL1 2009-04-27 11:19:34 -05:00
parent ec4e7b3594
commit 29fdd5ba66
4 changed files with 44 additions and 20 deletions

View file

@ -443,6 +443,22 @@ class ConvertAbsoluteToRelativePathCommands(unittest.TestCase):
'Absolute V command not converted to relative v command')
self.assertEquals(path[1][1][0], -20.0,
'Absolute V value not converted to relative v value')
class RoundPathData(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/path-precision.svg')
path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d'))
self.assertEquals(path[0][1][0][0], 100.0,
'Not rounding down' )
self.assertEquals(path[0][1][0][1], 100.0,
'Not rounding up' )
class LimitPrecisionInPathData(unittest.TestCase):
def runTest(self):
doc = scour.scourXmlFile('unittests/path-precision.svg')
path = svg_parser.parse(doc.getElementsByTagNameNS(SVGNS, 'path')[0].getAttribute('d'))
self.assertEquals(path[1][1][0], 100.001,
'Not correctly limiting precision on path data' )
if __name__ == '__main__':
unittest.main()