-
Notifications
You must be signed in to change notification settings - Fork 294
/
Copy pathQuadTree_Tests.cs
52 lines (45 loc) · 1.83 KB
/
QuadTree_Tests.cs
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
using System.Linq;
using Advanced.Algorithms.DataStructures;
using Advanced.Algorithms.Geometry;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Advanced.Algorithms.Tests.DataStructures
{
public class QuadTree_Tests
{
[TestClass]
public class QuadTreeTests
{
[TestMethod]
public void QuadTree_Smoke_Test()
{
var tree = new QuadTree<object>();
tree.Insert(new Point(0, 1));
tree.Insert(new Point(1, 1));
tree.Insert(new Point(2, 5));
tree.Insert(new Point(3, 6));
tree.Insert(new Point(4, 5));
tree.Insert(new Point(4, 7));
tree.Insert(new Point(5, 8));
tree.Insert(new Point(6, 9));
tree.Insert(new Point(7, 10));
var rangeResult = tree.RangeSearch(new Rectangle(new Point(1, 7), new Point(3, 1)));
Assert.IsTrue(rangeResult.Count == 3);
//IEnumerable test using linq
Assert.AreEqual(tree.Count, tree.Count());
tree.Delete(new Point(2, 5));
rangeResult = tree.RangeSearch(new Rectangle(new Point(1, 7), new Point(3, 1)));
Assert.IsTrue(rangeResult.Count == 2);
tree.Delete(new Point(3, 6));
rangeResult = tree.RangeSearch(new Rectangle(new Point(1, 7), new Point(3, 1)));
Assert.IsTrue(rangeResult.Count == 1);
tree.Delete(new Point(0, 1));
tree.Delete(new Point(1, 1));
tree.Delete(new Point(4, 5));
tree.Delete(new Point(4, 7));
tree.Delete(new Point(5, 8));
tree.Delete(new Point(6, 9));
tree.Delete(new Point(7, 10));
}
}
}
}