public void SortByPrimaryFitness() { const double champFitness = 100.0; var genomeComparerDescending = new GenomeComparerDescending(PrimaryFitnessInfoComparer.Singleton); IRandomSource rng = RandomDefaults.CreateRandomSource(0); // Run the inner test multiple times, with a different champ genome count each time. for (int champGenomeCount = 1; champGenomeCount <= 10; champGenomeCount++) { Species <double> species = CreateTestSpecies(10); AssignGenomeFitnessScores(species, champGenomeCount, champFitness, rng); ListSortUtils.SortUnstable(species.GenomeList, genomeComparerDescending, rng); // Assert that the champ genomes have been sorted to the head of the genome list. int idx = 0; for (; idx < champGenomeCount; idx++) { Assert.Equal(champFitness, species.GenomeList[idx].FitnessInfo.PrimaryFitness); } // Assert that all other genomes have a fitness less than the champ fitness. for (; idx < species.GenomeList.Count; idx++) { Assert.True(species.GenomeList[idx].FitnessInfo.PrimaryFitness < champFitness); } } }
public void IsSortedAscending_Comparer_String_NotSorted(params string[] arr) { Assert.False(ListSortUtils.IsSortedAscending(arr, Comparer <string> .Default)); }
public void IsSortedAscending_Comparer_Int_NotSorted(int[] arr) { Assert.False(ListSortUtils.IsSortedAscending(arr, Comparer <int> .Default)); }
public void IsSortedAscending_String_NotSorted(params string[] arr) { Assert.False(ListSortUtils.IsSortedAscending <string>(arr)); }
public void IsSortedAscending_Int_NotSorted(int[] arr) { Assert.False(ListSortUtils.IsSortedAscending <int>(arr)); }