Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11182


Ignore:
Timestamp:
07/10/14 17:38:08 (10 years ago)
Author:
ascheibe
Message:

#1886 added another unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/RealVectorSolutionCacheTest.cs

    r10105 r11182  
    2929  [TestClass]
    3030  public class RealVectorSolutionCacheTest {
     31    [TestMethod]
     32    public void TestComparer() {
     33      var rand = new HeuristicLab.Random.FastRandom();
     34      int nrOfVectors = 500000;
     35      int vectorLength = 4;
     36
     37      RealVectorEqualityComparer comp = new RealVectorEqualityComparer();
     38
     39      for (int i = 0; i < nrOfVectors; i++) {
     40        RealVector vector1 = new RealVector(vectorLength, rand, -20, 30);
     41        RealVector vector2 = new RealVector(vectorLength, rand, -20, 30);
     42        RealVector vector3 = SinglePointCrossover.Apply(rand, vector1, vector2);
     43
     44        bool result = comp.Equals(vector1, vector2);
     45        Assert.AreEqual(result, comp.GetHashCode(vector1) == comp.GetHashCode(vector2));
     46
     47        result = comp.Equals(vector1, vector3);
     48        Assert.AreEqual(result, comp.GetHashCode(vector1) == comp.GetHashCode(vector3));
     49
     50        result = comp.Equals(vector3, vector2);
     51        Assert.AreEqual(result, comp.GetHashCode(vector3) == comp.GetHashCode(vector2));
     52
     53        result = comp.Equals(vector3, vector3);
     54        Assert.AreEqual(result, comp.GetHashCode(vector3) == comp.GetHashCode(vector3));
     55
     56
     57      }
     58    }
     59
    3160    [TestMethod]
    3261    public void TestCache() {
Note: See TracChangeset for help on using the changeset viewer.