Adjust a unittest

(latest optimizations already paid off ;-) )
This commit is contained in:
Eduard Braun 2017-05-17 02:51:10 +02:00
parent f0865ed96f
commit f1827735a7
3 changed files with 13 additions and 13 deletions

View file

@ -2445,7 +2445,7 @@ def cleanPath(element, options):
# m expects two parameters but we have to skip the first pair as it's not drawn (so we need at least 6) # m expects two parameters but we have to skip the first pair as it's not drawn (so we need at least 6)
elif cmd is 'm' and len(data) >= 6: elif cmd is 'm' and len(data) >= 6:
coordIndex = 2; coordIndex = 2
while coordIndex+2 < len(data): while coordIndex+2 < len(data):
if is_same_direction(*data[coordIndex:coordIndex+4]): if is_same_direction(*data[coordIndex:coordIndex+4]):
data[coordIndex] += data[coordIndex+2] data[coordIndex] += data[coordIndex+2]

View file

@ -964,10 +964,10 @@ class KeepPrecisionInPathDataIfSameLength(unittest.TestCase):
doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=1'])) doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=1']))
paths = doc.getElementsByTagNameNS(SVGNS, 'path') paths = doc.getElementsByTagNameNS(SVGNS, 'path')
for path in paths[1:3]: for path in paths[1:3]:
self.assertEqual(path.getAttribute('d'), "m1 12 123 1e3 1e4 1e5", self.assertEqual(path.getAttribute('d'), "m1 21 321 4e3 5e4 7e5",
'Precision not correctly reduced with "--set-precision=1" ' 'Precision not correctly reduced with "--set-precision=1" '
'for path with ID ' + path.getAttribute('id')) 'for path with ID ' + path.getAttribute('id'))
self.assertEqual(paths[4].getAttribute('d'), "m-1-12-123-1e3 -1e4 -1e5", self.assertEqual(paths[4].getAttribute('d'), "m-1-21-321-4e3 -5e4 -7e5",
'Precision not correctly reduced with "--set-precision=1" ' 'Precision not correctly reduced with "--set-precision=1" '
'for path with ID ' + paths[4].getAttribute('id')) 'for path with ID ' + paths[4].getAttribute('id'))
self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101", self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101",
@ -977,10 +977,10 @@ class KeepPrecisionInPathDataIfSameLength(unittest.TestCase):
doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=2'])) doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=2']))
paths = doc.getElementsByTagNameNS(SVGNS, 'path') paths = doc.getElementsByTagNameNS(SVGNS, 'path')
for path in paths[1:3]: for path in paths[1:3]:
self.assertEqual(path.getAttribute('d'), "m1 12 123 1234 12345 1.2e5", self.assertEqual(path.getAttribute('d'), "m1 21 321 4321 54321 6.5e5",
'Precision not correctly reduced with "--set-precision=2" ' 'Precision not correctly reduced with "--set-precision=2" '
'for path with ID ' + path.getAttribute('id')) 'for path with ID ' + path.getAttribute('id'))
self.assertEqual(paths[4].getAttribute('d'), "m-1-12-123-1234-12345-1.2e5", self.assertEqual(paths[4].getAttribute('d'), "m-1-21-321-4321-54321-6.5e5",
'Precision not correctly reduced with "--set-precision=2" ' 'Precision not correctly reduced with "--set-precision=2" '
'for path with ID ' + paths[4].getAttribute('id')) 'for path with ID ' + paths[4].getAttribute('id'))
self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101", self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101",
@ -990,10 +990,10 @@ class KeepPrecisionInPathDataIfSameLength(unittest.TestCase):
doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=3'])) doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=3']))
paths = doc.getElementsByTagNameNS(SVGNS, 'path') paths = doc.getElementsByTagNameNS(SVGNS, 'path')
for path in paths[1:3]: for path in paths[1:3]:
self.assertEqual(path.getAttribute('d'), "m1 12 123 1234 12345 123456", self.assertEqual(path.getAttribute('d'), "m1 21 321 4321 54321 654321",
'Precision not correctly reduced with "--set-precision=3" ' 'Precision not correctly reduced with "--set-precision=3" '
'for path with ID ' + path.getAttribute('id')) 'for path with ID ' + path.getAttribute('id'))
self.assertEqual(paths[4].getAttribute('d'), "m-1-12-123-1234-12345-123456", self.assertEqual(paths[4].getAttribute('d'), "m-1-21-321-4321-54321-654321",
'Precision not correctly reduced with "--set-precision=3" ' 'Precision not correctly reduced with "--set-precision=3" '
'for path with ID ' + paths[4].getAttribute('id')) 'for path with ID ' + paths[4].getAttribute('id'))
self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101", self.assertEqual(paths[5].getAttribute('d'), "m123 101-123-101",
@ -1003,10 +1003,10 @@ class KeepPrecisionInPathDataIfSameLength(unittest.TestCase):
doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=4'])) doc = scourXmlFile('unittests/path-precision.svg', parse_args(['--set-precision=4']))
paths = doc.getElementsByTagNameNS(SVGNS, 'path') paths = doc.getElementsByTagNameNS(SVGNS, 'path')
for path in paths[1:3]: for path in paths[1:3]:
self.assertEqual(path.getAttribute('d'), "m1 12 123 1234 12345 123456", self.assertEqual(path.getAttribute('d'), "m1 21 321 4321 54321 654321",
'Precision not correctly reduced with "--set-precision=4" ' 'Precision not correctly reduced with "--set-precision=4" '
'for path with ID ' + path.getAttribute('id')) 'for path with ID ' + path.getAttribute('id'))
self.assertEqual(paths[4].getAttribute('d'), "m-1-12-123-1234-12345-123456", self.assertEqual(paths[4].getAttribute('d'), "m-1-21-321-4321-54321-654321",
'Precision not correctly reduced with "--set-precision=4" ' 'Precision not correctly reduced with "--set-precision=4" '
'for path with ID ' + paths[4].getAttribute('id')) 'for path with ID ' + paths[4].getAttribute('id'))
self.assertEqual(paths[5].getAttribute('d'), "m123.5 101-123.5-101", self.assertEqual(paths[5].getAttribute('d'), "m123.5 101-123.5-101",

View file

@ -2,10 +2,10 @@
<svg xmlns="http://www.w3.org/2000/svg"> <svg xmlns="http://www.w3.org/2000/svg">
<path id="p0" d="M 100.0000001 99.9999999 h100.01 v123456789.123456789 h-100 z" /> <path id="p0" d="M 100.0000001 99.9999999 h100.01 v123456789.123456789 h-100 z" />
<path id="p1" d="m 1 12 123 1234 12345 123456 " /> <path id="p1" d="m 1 21 321 4321 54321 654321 " />
<path id="p2" d="m 1.0 12.0 123.0 1234.0 12345.0 123456.0" /> <path id="p2" d="m 1.0 21.0 321.0 4321.0 54321.0 654321.0" />
<path id="p3" d="m 01 012 0123 01234 012345 0123456 " /> <path id="p3" d="m 01 021 0321 04321 054321 0654321 " />
<path id="p4" d="m -1 -12 -123 -1234 -12345 -123456 " /> <path id="p4" d="m -1 -21 -321 -4321 -54321 -654321 " />
<path id="p6" d="m 123.456 101.001 -123.456 -101.001" /> <path id="p6" d="m 123.456 101.001 -123.456 -101.001" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 517 B

After

Width:  |  Height:  |  Size: 517 B

Before After
Before After