public void convex_hull_test() { Location[] loc = new Location[7]; Cluster clust = new Cluster(); List<Location> expected = new List<Location>(); loc[0] = new Location(3, 2); loc[1] = new Location(3, 3); loc[2] = new Location(3, 4); loc[3] = new Location(2, 3); loc[4] = new Location(2, 1); loc[5] = new Location(1, 2); loc[6] = new Location(1, 4); clust.add_location(loc[0]); clust.add_location(loc[1]); clust.add_location(loc[2]); clust.add_location(loc[3]); clust.add_location(loc[4]); clust.add_location(loc[5]); clust.add_location(loc[6]); expected.Add(loc[4]); expected.Add(loc[5]); expected.Add(loc[6]); expected.Add(loc[2]); expected.Add(loc[1]); expected.Add(loc[0]); List<Location> ch = clust.convex_hull(); for(int i = 0; i < 4; i++) { Specify.That(ch[i].Equals(expected[i])).ShouldBeTrue(); } }
public void second_convex_hull_test() { Cluster clust = new Cluster(); List<Location> expected = new List<Location>(); Location[] loc = new Location[] { new Location(2, 0), new Location(0, 2), new Location(2, 4), new Location(2, 1), new Location(2, 2), new Location(4, 2) }; clust.add_location(loc[0]); clust.add_location(loc[1]); clust.add_location(loc[2]); clust.add_location(loc[3]); clust.add_location(loc[4]); clust.add_location(loc[5]); expected.Add(loc[0]); expected.Add(loc[1]); expected.Add(loc[3]); expected.Add(loc[5]); List<Location> ch = clust.convex_hull(); for (int i = 0; i < 4; i++) { Specify.That(ch[i]).ShouldEqual(expected[i]); } }