[6507] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[14185] | 3 | * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[6507] | 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using Microsoft.VisualStudio.TestTools.UnitTesting;
|
---|
| 23 |
|
---|
[9764] | 24 | namespace HeuristicLab.Encodings.PermutationEncoding.Tests {
|
---|
[6507] | 25 | [TestClass]
|
---|
| 26 | public class PermutationEqualityComparerTest {
|
---|
| 27 | [TestMethod]
|
---|
[9777] | 28 | [TestCategory("Encodings.Permutation")]
|
---|
| 29 | [TestProperty("Time", "short")]
|
---|
[6507] | 30 | public void TestPermutationEqualityComparer() {
|
---|
| 31 | PermutationEqualityComparer comparer = new PermutationEqualityComparer();
|
---|
| 32 | Permutation p = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 2, 0, 1, 4 });
|
---|
| 33 | Permutation q = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 1, 0, 2, 3, 4 });
|
---|
| 34 | Assert.IsTrue(comparer.Equals(p, q));
|
---|
| 35 | Assert.IsTrue(comparer.GetHashCode(p) == comparer.GetHashCode(q));
|
---|
| 36 | Permutation p2 = new Permutation(PermutationTypes.RelativeDirected, new int[] { 2, 3, 4, 1, 0 });
|
---|
| 37 | Permutation q2 = new Permutation(PermutationTypes.RelativeDirected, new int[] { 1, 0, 2, 3, 4 });
|
---|
| 38 | Assert.IsTrue(comparer.Equals(p2, q2));
|
---|
| 39 | Assert.IsTrue(comparer.GetHashCode(p2) == comparer.GetHashCode(q2));
|
---|
| 40 |
|
---|
| 41 | Assert.IsFalse(comparer.Equals(p, q2));
|
---|
| 42 | Assert.IsFalse(comparer.Equals(p2, q));
|
---|
| 43 |
|
---|
| 44 | Permutation p3 = new Permutation(PermutationTypes.Absolute, new int[] { 2, 3, 0, 4, 1 });
|
---|
| 45 | Permutation q3 = new Permutation(PermutationTypes.Absolute, new int[] { 2, 3, 0, 4, 1 });
|
---|
| 46 | Assert.IsTrue(comparer.Equals(p3, q3));
|
---|
| 47 | Assert.IsTrue(comparer.GetHashCode(p3) == comparer.GetHashCode(q3));
|
---|
| 48 |
|
---|
| 49 | Assert.IsFalse(comparer.Equals(p3, q));
|
---|
| 50 | Assert.IsFalse(comparer.Equals(p2, q3));
|
---|
| 51 |
|
---|
| 52 | Permutation p4 = new Permutation(PermutationTypes.RelativeUndirected, new int[] { 3, 2, 0, 1, 4, 5 });
|
---|
| 53 | Assert.IsFalse(comparer.Equals(p, p4));
|
---|
| 54 | Assert.IsFalse(comparer.Equals(p4, q));
|
---|
| 55 | }
|
---|
| 56 | }
|
---|
| 57 | }
|
---|