MCPcopy Index your code
hub / github.com/OmkarPathak/pygorithm / test_split_empty

Method test_split_empty

tests/test_data_structure.py:490–543  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

488 self.assertEqual(-1, _tree.get_quadrant(ent5))
489
490 def test_split_empty(self):
491 _tree1 = quadtree.QuadTree(64, 5, self.big_rect)
492 self.assertIsNone(_tree1.children)
493 _tree1.split()
494 self.assertIsNotNone(_tree1.children)
495 self.assertEqual(4, len(_tree1.children))
496
497 self.assertEqual(500, _tree1.children[0].location.width)
498 self.assertEqual(500, _tree1.children[0].location.height)
499 self.assertEqual(0, _tree1.children[0].location.mincorner.x)
500 self.assertEqual(0, _tree1.children[0].location.mincorner.y)
501 self.assertEqual(1, _tree1.children[0].depth)
502 self.assertEqual(64, _tree1.children[0].bucket_size)
503 self.assertEqual(5, _tree1.children[0].max_depth)
504
505 self.assertEqual(500, _tree1.children[1].location.width)
506 self.assertEqual(500, _tree1.children[1].location.height)
507 self.assertEqual(500, _tree1.children[1].location.mincorner.x)
508 self.assertEqual(0, _tree1.children[1].location.mincorner.y)
509
510 self.assertEqual(500, _tree1.children[2].location.width)
511 self.assertEqual(500, _tree1.children[2].location.height)
512 self.assertEqual(500, _tree1.children[2].location.mincorner.x)
513 self.assertEqual(500, _tree1.children[2].location.mincorner.y)
514
515 self.assertEqual(500, _tree1.children[3].location.width)
516 self.assertEqual(500, _tree1.children[3].location.height)
517 self.assertEqual(0, _tree1.children[3].location.mincorner.x)
518 self.assertEqual(500, _tree1.children[3].location.mincorner.y)
519
520 # bottom-right
521 _tree2 = _tree1.children[2]
522 _tree2.split()
523
524 self.assertEqual(250, _tree2.children[0].location.width)
525 self.assertEqual(250, _tree2.children[0].location.height)
526 self.assertEqual(500, _tree2.children[0].location.mincorner.x)
527 self.assertEqual(500, _tree2.children[0].location.mincorner.y)
528 self.assertEqual(2, _tree2.children[0].depth)
529
530 self.assertEqual(250, _tree2.children[1].location.width)
531 self.assertEqual(250, _tree2.children[1].location.height)
532 self.assertEqual(750, _tree2.children[1].location.mincorner.x)
533 self.assertEqual(500, _tree2.children[1].location.mincorner.y)
534
535 self.assertEqual(250, _tree2.children[2].location.width)
536 self.assertEqual(250, _tree2.children[2].location.height)
537 self.assertEqual(750, _tree2.children[2].location.mincorner.x)
538 self.assertEqual(750, _tree2.children[2].location.mincorner.y)
539
540 self.assertEqual(250, _tree2.children[3].location.width)
541 self.assertEqual(250, _tree2.children[3].location.height)
542 self.assertEqual(500, _tree2.children[3].location.mincorner.x)
543 self.assertEqual(750, _tree2.children[3].location.mincorner.y)
544
545 def test_split_entities(self):
546

Callers

nothing calls this directly

Calls 1

splitMethod · 0.95

Tested by

no test coverage detected