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.

Location:
trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/NPointCrossoverTest.cs

    r14185 r14353  
    2020#endregion
    2121
     22using HeuristicLab.Core;
    2223using HeuristicLab.Data;
    2324using HeuristicLab.Tests;
     
    3132  [TestClass()]
    3233  public class NPointCrossoverTest {
     34    /// <summary>
     35    ///A test for Cross
     36    ///</summary>
     37    [TestMethod]
     38    [TestCategory("Encodings.BinaryVector")]
     39    [TestProperty("Time", "short")]
     40    public void NPointCrossoverCrossTest() {
     41      var privateObject = new PrivateObject(typeof(NPointCrossover));
     42      ItemArray<BinaryVector> parents;
     43      TestRandom random = new TestRandom();
     44      bool exceptionFired;
     45      // The following test checks if there is an exception when there are more than 2 parents
     46      random.Reset();
     47      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(5), new BinaryVector(6), new BinaryVector(4) });
     48      exceptionFired = false;
     49      try {
     50        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (System.ArgumentException) {
     53        exceptionFired = true;
     54      }
     55      Assert.IsTrue(exceptionFired);
     56      // The following test checks if there is an exception when there are less than 2 parents
     57      random.Reset();
     58      parents = new ItemArray<BinaryVector>(new BinaryVector[] { new BinaryVector(4) });
     59      exceptionFired = false;
     60      try {
     61        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (System.ArgumentException) {
     64        exceptionFired = true;
     65      }
     66      Assert.IsTrue(exceptionFired);
     67    }
     68
    3369    /// <summary>
    3470    ///A test for Apply
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/SinglePointCrossoverTest.cs

    r13129 r14353  
    3939    [TestProperty("Time", "short")]
    4040    public void SinglePointCrossoverCrossTest() {
    41       SinglePointCrossover_Accessor target = new SinglePointCrossover_Accessor(new PrivateObject(typeof(SinglePointCrossover)));
     41      var privateObject = new PrivateObject(typeof(SinglePointCrossover));
    4242      ItemArray<BinaryVector> parents;
    4343      TestRandom random = new TestRandom();
     
    4848      exceptionFired = false;
    4949      try {
    50         BinaryVector actual;
    51         actual = target.Cross(random, parents);
    52       } catch (ArgumentException) {
     50        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     51      }
     52      catch (ArgumentException) {
    5353        exceptionFired = true;
    5454      }
     
    5959      exceptionFired = false;
    6060      try {
    61         BinaryVector actual;
    62         actual = target.Cross(random, parents);
    63       } catch (ArgumentException) {
     61        var actual = (BinaryVector)privateObject.Invoke("Cross", random, parents);
     62      }
     63      catch (ArgumentException) {
    6464        exceptionFired = true;
    6565      }
  • trunk/sources/HeuristicLab.Tests/HeuristicLab.Encodings.BinaryVectorEncoding-3.3/UniformCrossoverTest.cs

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