#region License Information /* HeuristicLab * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace AlgorithmBehaviorUnitTests { [TestClass] public class LPConvexHullSortingTest { [TestMethod] public void TestSorting() { int size = 4; int dimension = 2; double[][] points = new double[size][]; points[0] = new double[] { 2, 3 }; points[1] = new double[] { 6, 4 }; points[2] = new double[] { 12, 13 }; points[3] = new double[] { 21, 31 }; var result = LPHull.SortA(points); for (int i = 0; i < size; i++) { for (int j = 0; j < dimension; j++) { Assert.AreEqual(points[i][j], result[size - i - 1][j]); } } } [TestMethod] public void TestSortingNegative() { int size = 4; int dimension = 2; double[][] points = new double[size][]; points[0] = new double[] { -6, -4 }; points[1] = new double[] { -2, -3 }; points[2] = new double[] { 12, 13 }; points[3] = new double[] { 21, 31 }; var result = LPHull.SortA(points); for (int i = 0; i < size; i++) { for (int j = 0; j < dimension; j++) { Assert.AreEqual(points[i][j], result[size - i - 1][j]); } } } [TestMethod] public void TestSortingMixed() { int size = 4; double[][] points = new double[size][]; points[0] = new double[] { -6, -4 }; points[2] = new double[] { 5, 13 }; points[1] = new double[] { -2, -3 }; points[3] = new double[] { 21, 31 }; var result = LPHull.SortA(points); Assert.AreEqual(21, result[0][0]); Assert.AreEqual(5, result[1][0]); Assert.AreEqual(-2, result[2][0]); Assert.AreEqual(-6, result[3][0]); } } }