Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/23/16 19:31:18 (8 years ago)
Author:
bburlacu
Message:

#2685: Add correction step for values miscalculated due to cyclical symbol dependencies in the grammar. Updated unit test.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.RealVectorEncoding-3.3/HeuristicCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Tests;
    2324using Microsoft.VisualStudio.TestTools.UnitTesting;
     
    3031  [TestClass()]
    3132  public class HeuristicCrossoverTest {
     33    /// <summary>
     34    ///A test for Cross
     35    ///</summary>
     36    [TestMethod()]
     37    [TestCategory("Encodings.RealVector")]
     38    [TestProperty("Time", "short")]
     39    public void HeuristicCrossoverCrossTest() {
     40      var privateObject = new PrivateObject(typeof(HeuristicCrossover));
     41      ItemArray<RealVector> parents;
     42      TestRandom random = new TestRandom();
     43      bool exceptionFired;
     44      // The following test checks if there is an exception when there are more than 2 parents
     45      random.Reset();
     46      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(5), new RealVector(6), new RealVector(4) });
     47      exceptionFired = false;
     48      try {
     49        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     50      }
     51      catch (System.ArgumentException) {
     52        exceptionFired = true;
     53      }
     54      Assert.IsTrue(exceptionFired);
     55      // The following test checks if there is an exception when there are less than 2 parents
     56      random.Reset();
     57      parents = new ItemArray<RealVector>(new RealVector[] { new RealVector(4) });
     58      exceptionFired = false;
     59      try {
     60        var actual = (RealVector)privateObject.Invoke("Cross", random, parents);
     61      }
     62      catch (System.ArgumentException) {
     63        exceptionFired = true;
     64      }
     65      Assert.IsTrue(exceptionFired);
     66    }
     67
    3268    /// <summary>
    3369    ///A test for Apply
Note: See TracChangeset for help on using the changeset viewer.