about summary refs log tree commit diff
path: root/structs_test.go
blob: 66598bf9faf20b64205c93cb6d5e7a1972f25f6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
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)
}