Skip to content

Commit

Permalink
Code coverage improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
giacomelli committed Sep 11, 2022
1 parent 616276e commit 9130fca
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Parse_SampleString_ConsistantCells()

var sudoku = SudokuTestHelper.CreateBoard(SudokuTestDifficulty.VeryEasy);

Assert.AreEqual(sudoku.Cells[0], 9);
Assert.AreEqual(sudoku.GetCell(0, 0), 9);
Assert.AreEqual(sudoku.Cells[1], 0);
Assert.AreEqual(sudoku.Cells[2], 2);
Assert.AreEqual(sudoku.Cells[sudoku.Cells.Count - 2], 5);
Expand Down
2 changes: 1 addition & 1 deletion src/GeneticSharp.Extensions/Multiple/MultipleFitness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public double Evaluate(MultipleChromosome chromosome)
/// <returns>an aggregated global fitness</returns>
private static double ApplyAggregator(IEnumerable<IChromosome> childChromosomes, IFitness individualFitness, Func<IEnumerable<IChromosome>, Func<IChromosome, double>, double> aggregator)
{
var chromosomesEnumerated = childChromosomes as IList<IChromosome> ?? childChromosomes.ToList();
var chromosomesEnumerated = childChromosomes.ToList();
foreach (var childChromosome in chromosomesEnumerated)
{
childChromosome.Fitness = individualFitness.Evaluate(childChromosome);
Expand Down
10 changes: 1 addition & 9 deletions src/GeneticSharp.Extensions/Sudoku/SudokuChromosomeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,13 @@ public abstract class SudokuChromosomeBase : ChromosomeBase, ISudokuChromosome
/// </summary>
private Dictionary<int, List<int>> _extendedMask;


/// <summary>
/// Constructor that accepts a Sudoku to solve
/// </summary>
/// <param name="targetSudokuBoard">the target sudoku to solve</param>
/// <param name="length">The number of genes for the sudoku chromosome</param>
public SudokuChromosomeBase(SudokuBoard targetSudokuBoard, int length) : this(targetSudokuBoard, null, length) {}

/// <summary>
/// Constructor that accepts an additional extended mask for quick cloning
/// </summary>
/// <param name="targetSudokuBoard">the target sudoku to solve</param>
/// <param name="extendedMask">The cell domains after initial constraint propagation</param>
/// <param name="length">The number of genes for the sudoku chromosome</param>
public SudokuChromosomeBase(SudokuBoard targetSudokuBoard, Dictionary<int, List<int>> extendedMask, int length) : base(length)
protected SudokuChromosomeBase(SudokuBoard targetSudokuBoard, Dictionary<int, List<int>> extendedMask, int length) : base(length)
{
_targetSudokuBoard = targetSudokuBoard;
_extendedMask = extendedMask;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ public SudokuPermutationsChromosome(SudokuBoard targetSudokuBoard) : this(target
/// </summary>
/// <param name="targetSudokuBoard">the target sudoku to solve</param>
/// <param name="length">the number of genes</param>
public SudokuPermutationsChromosome(SudokuBoard targetSudokuBoard, int length) : this(targetSudokuBoard, null, length) {}

/// <summary>
/// /// Constructor with a mask and extended mask accounting for initial constraint propagation for faster cloning
/// </summary>
/// <param name="targetSudokuBoard">the target sudoku to solve</param>
/// <param name="extendedMask">The cell domains after initial constraint propagation</param>
public SudokuPermutationsChromosome(SudokuBoard targetSudokuBoard, Dictionary<int, List<int>> extendedMask) : this(targetSudokuBoard, extendedMask, 9) {}
public SudokuPermutationsChromosome(SudokuBoard targetSudokuBoard, int length) : this(targetSudokuBoard, null, length) {}

/// <param name="targetSudokuBoard">the target sudoku to solve</param>
/// <param name="extendedMask">The cell domains after initial constraint propagation</param>
Expand Down

0 comments on commit 9130fca

Please sign in to comment.