0

RendertileSet: Round-robin the four top-level subtrees

This commit is contained in:
Johan Kiviniemi
2013-12-27 08:36:12 +02:00
parent e4638467ef
commit c49fdd19e1
2 changed files with 84 additions and 11 deletions

View File

@@ -1,6 +1,7 @@
import unittest
from overviewer_core.tileset import iterate_base4, RendertileSet
from overviewer_core.util import roundrobin
class RendertileSetTest(unittest.TestCase):
# If you change this definition, you must also change the hard-coded
@@ -196,6 +197,65 @@ class RendertileSetTest(unittest.TestCase):
self.assertRaises(StopIteration, next, iterator)
def test_posttraverse_roundrobin(self):
"""Test a round-robin post-traversal of the tree's dirty tiles"""
# Expect these results in this proper order.
expected_lists = [
[
(0,0,3),
(0,0,1),
(0,0,2),
(0,0,0),
(0,0),
(0,),
],
[
(1,2,0),
(1,2),
(1,0,3),
(1,0),
(1,1,3),
(1,1),
(1,),
],
[
(2,1,1),
(2,1,0),
(2,1,3),
(2,1,2),
(2,1),
(2,0,1),
(2,0,3),
(2,0,0),
(2,0,2),
(2,0),
(2,3,1),
(2,3,0),
(2,3,3),
(2,3,2),
(2,3),
(2,2,1),
(2,2,0),
(2,2,3),
(2,2,2),
(2,2),
(2,),
],
]
expected_list = list(roundrobin(expected_lists)) + [ () ]
iterator = iter(self.tree.posttraversal(robin=True))
from itertools import izip
for expected, actual in izip(expected_list, iterator):
self.assertEqual(actual, expected)
self.assertRaises(StopIteration, next, iterator)
def test_count_all(self):
"""Tests getting a count of all tiles (render tiles plus upper tiles)