From 434e3dc2f25ffa8ff2d302dee2495ade6167c6d5 Mon Sep 17 00:00:00 2001 From: hanemile Date: Sat, 3 Nov 2018 19:41:14 +0100 Subject: Added a test that tests printing a quadtree --- structs_test.go | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/structs_test.go b/structs_test.go index cc62016..4be947b 100644 --- a/structs_test.go +++ b/structs_test.go @@ -161,6 +161,91 @@ func TestInsert(t *testing.T) { } +// test printing a quadtree +func TestPrint(t *testing.T) { + + // Define a testQuadTree + var testQuadTree = Quadtree{ + nodeCapacity: 0, + boundary: BoundingBox{ + center: Coord{ + x: 0, + y: 0, + }, + halfDimension: 4, + }, + pointsSlice: nil, + northWest: &Quadtree{ + nodeCapacity: 0, + boundary: BoundingBox{ + center: Coord{ + x: 2, + y: 2, + }, + halfDimension: 2, + }, + pointsSlice: nil, + northWest: &Quadtree{}, + northEast: &Quadtree{}, + southWest: &Quadtree{}, + southEast: &Quadtree{}, + depth: 1, + }, + northEast: &Quadtree{ + nodeCapacity: 0, + boundary: BoundingBox{ + center: Coord{ + x: -2, + y: 2, + }, + halfDimension: 2, + }, + pointsSlice: nil, + northWest: &Quadtree{}, + northEast: &Quadtree{}, + southWest: &Quadtree{}, + southEast: &Quadtree{}, + depth: 1, + }, + southWest: &Quadtree{ + nodeCapacity: 0, + boundary: BoundingBox{ + center: Coord{ + x: 2, + y: -2, + }, + halfDimension: 2, + }, + pointsSlice: nil, + northWest: &Quadtree{}, + northEast: &Quadtree{}, + southWest: &Quadtree{}, + southEast: &Quadtree{}, + depth: 1, + }, + southEast: &Quadtree{ + nodeCapacity: 0, + boundary: BoundingBox{ + center: Coord{ + x: -2, + y: -2, + }, + halfDimension: 2, + }, + pointsSlice: nil, + northWest: &Quadtree{}, + northEast: &Quadtree{}, + southWest: &Quadtree{}, + southEast: &Quadtree{}, + depth: 1, + }, + depth: 0, + } + + // Print the test-QuadTree + testQuadTree.Print() +} + /*############################################################ BEYOND THIS POINT: EXAMPLES ############################################################*/ -- cgit 1.4.1