package quadtree import ( "testing" ) // Quadtree Test func TestQuadtree(t *testing.T) { testQuadtree := quadtree{ nodeCapacity: 0, boundary: boundingBox{}, pointsSlice: nil, northWest: nil, northEast: nil, southWest: nil, southEast: nil, } t.Log(testQuadtree) } // NewQuadTree test func TestNewQuadtree(t *testing.T) { var boundary = boundingBox{ center: Coord{0, 0}, halfDimension: 3, } var newQuadtree = *newQuadtree(boundary, 0) t.Log(newQuadtree) } // Coordinate Test func TestCoord(t *testing.T) { testCoord := Coord{ x: 0, y: 1, } t.Log(testCoord) } // NewCoord test func TestNewCoord(t *testing.T) { var newCoordinate = NewCoord(1, 2) t.Log(newCoordinate) } func TestBoundingBox(t *testing.T) { var newBoundingBox = boundingBox{ center: Coord{ x: 1, y: 2, }, halfDimension: 3, } t.Log(newBoundingBox) } func TestInsideOf(t *testing.T) { var testCoordinate = Coord{0, 0} var testQuadTree = newQuadtree(boundingBox{ center: Coord{ x: 0, y: 0, }, halfDimension: 1, }, 0) var isInsideOf = testCoordinate.insideOf(testQuadTree) t.Log(isInsideOf) } // Test the newBoundingBox function func TestNewBoundingBox(t *testing.T) { // Initialize some values that are needed var newCenter = Coord{1, 2} var newHalfDimension float64 = 3 // Initialize the bounding box using the values above var newBoundingBox = newBoundingBox(newCenter, newHalfDimension) // Print the newBoundingBox t.Log(newBoundingBox) } func TestSubdivide(t *testing.T) { var boundary = boundingBox{ center: Coord{0, 0}, halfDimension: 3, } var newQuadtree = *newQuadtree(boundary, 0) newQuadtree.subdivide() t.Logf("newQuadTree: %v\n", newQuadtree) t.Logf("NorthWestCell: %v\n", newQuadtree.northWest) t.Logf("NorthEestCell: %v\n", newQuadtree.northEast) t.Logf("SouthWestCell: %v\n", newQuadtree.southWest) t.Logf("SouthEastCell: %v\n", newQuadtree.southEast) } // test the insert function func TestInsert(t *testing.T) { // Define a new quadtree-root-boundary var boundary = boundingBox{ center: Coord{0, 0}, halfDimension: 3, } // create a new quadtree using the boundary var newQuadtree = *newQuadtree(boundary, 0) // Define a star and insert it into the quadtree singleCoord := Coord{0.5, 0.5} newQuadtree.insert(singleCoord) // Print the stuff generated t.Logf("Complete Tree: %v\n", newQuadtree.northEast.southWest.southWest.northEast) }