Skip to content

Commit

Permalink
allocator tests tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyLloyd committed Nov 24, 2023
1 parent 2e43ca5 commit fc6bd86
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Tests/Allocator_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,31 +134,33 @@ static bool GivesSameResultReorderedForReorderedWeights<W>(long quantity, W[] we
{
var allocations = allocate(quantity, weights);
var shuffledAllocations = allocate(quantity, shuffled);
return weights.Zip(allocations).Order().Zip(shuffled.Zip(shuffledAllocations).Order()).All(i => Equals(i.First, i.Second));
return weights.Zip(allocations).Order().Zip(
shuffled.Zip(shuffledAllocations).Order())
.All(i => Equals(i.First, i.Second));
}

[Fact]
public void Allocate_GivesSameResultReorderedForReorderedWeights()
{
genAllSigns.SelectMany((q, w) => Gen.Shuffle(w).Select(s => (q, w, s)))
.Sample((quantity, weights, shuffled) => GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate)
, output.WriteLine);
.Sample((quantity, weights, shuffled)
=> GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate));
}

[Fact]
public void Allocate_Long_GivesSameResultReorderedForReorderedWeights()
{
genAllSignsLong.SelectMany((q, w) => Gen.Shuffle(w).Select(s => (q, w, s)))
.Sample((quantity, weights, shuffled) => GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate)
, output.WriteLine);
.Sample((quantity, weights, shuffled)
=> GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate));
}

[Fact]
public void Allocate_BalinskiYoung_GivesSameResultReorderedForReorderedWeights()
{
genPositive.SelectMany((q, w) => Gen.Shuffle(w).Select(s => (q, w, s)))
.Sample((quantity, weights, shuffled) => GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate_BalinskiYoung)
, output.WriteLine);
.Sample((quantity, weights, shuffled)
=> GivesSameResultReorderedForReorderedWeights(quantity, weights, shuffled, Allocator.Allocate_BalinskiYoung));
}

[Fact]
Expand Down

0 comments on commit fc6bd86

Please sign in to comment.