about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--structs_test.go85
1 files changed, 85 insertions, 0 deletions
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
 ############################################################*/