fix: add the forgotten test file

Now the test-suite should pass again on master.
pull/8/head
Dominique Merle 3 years ago
parent ba83ad8224
commit ba46d3db50

@ -2,6 +2,7 @@ package fr.mieuxvoter.mj;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
import java.math.BigInteger;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.DisplayName;
@ -21,13 +22,13 @@ class ProposalTallyAnalysisTest {
String testName, String testName,
Integer[] rawTally, Integer[] rawTally,
Integer medianGrade, Integer medianGrade,
Long medianGroupSize, BigInteger medianGroupSize,
Integer contestationGrade, Integer contestationGrade,
Long contestationGroupSize, BigInteger contestationGroupSize,
Integer adhesionGrade, Integer adhesionGrade,
Long adhesionGroupSize, BigInteger adhesionGroupSize,
Integer secondMedianGrade, Integer secondMedianGrade,
Long secondMedianGroupSize, BigInteger secondMedianGroupSize,
Integer secondMedianGroupSign Integer secondMedianGroupSign
) { ) {
ProposalTally tally = new ProposalTally(rawTally); ProposalTally tally = new ProposalTally(rawTally);
@ -44,124 +45,111 @@ class ProposalTallyAnalysisTest {
} }
protected static Stream<Arguments> testProvider() { protected static Stream<Arguments> testProvider() {
return Stream.of( return Stream.of(
// Arguments.of( Arguments.of(
// /* name */ "Void tallies yield ???", // perhaps raise ? later /* name */ "Very empty tallies yield zeroes",
// /* tally */ new Integer[]{}, /* tally */ new Integer[]{ 0 },
// /* medianGrade */ 0, /* medianGrade */ 0,
// /* medianGroupSize */ 0, /* medianGroupSize */ BigInteger.ZERO,
// /* contestationGrade */ 0, /* contestationGrade */ 0,
// /* contestationGroupSize */ 0, /* contestationGroupSize */ BigInteger.ZERO,
// /* adhesionGrade */ 0, /* adhesionGrade */ 0,
// /* adhesionGroupSize */ 0, /* adhesionGroupSize */ BigInteger.ZERO,
// /* secondMedianGrade */ 0, /* secondMedianGrade */ 0,
// /* secondMedianGroupSize */ 0, /* secondMedianGroupSize */ BigInteger.ZERO,
// /* secondMedianGroupSign */ 0 /* secondMedianGroupSign */ 0
// ), ),
Arguments.of( Arguments.of(
/* name */ "Very empty tallies yield zeroes", /* name */ "Empty tallies yield zeroes",
/* tally */ new Integer[]{ 0 }, /* tally */ new Integer[]{ 0, 0, 0, 0 },
/* medianGrade */ 0, /* medianGrade */ 0,
/* medianGroupSize */ 0L, /* medianGroupSize */ BigInteger.ZERO,
/* contestationGrade */ 0, /* contestationGrade */ 0,
/* contestationGroupSize */ 0L, /* contestationGroupSize */ BigInteger.ZERO,
/* adhesionGrade */ 0, /* adhesionGrade */ 0,
/* adhesionGroupSize */ 0L, /* adhesionGroupSize */ BigInteger.ZERO,
/* secondMedianGrade */ 0, /* secondMedianGrade */ 0,
/* secondMedianGroupSize */ 0L, /* secondMedianGroupSize */ BigInteger.ZERO,
/* secondMedianGroupSign */ 0 /* secondMedianGroupSign */ 0
), ),
Arguments.of( Arguments.of(
/* name */ "Empty tallies yield zeroes", /* name */ "Absurd tally of 1 Grade",
/* tally */ new Integer[]{ 0, 0, 0, 0 }, /* tally */ new Integer[]{ 7 },
/* medianGrade */ 0, /* medianGrade */ 0,
/* medianGroupSize */ 0L, /* medianGroupSize */ BigInteger.valueOf(7),
/* contestationGrade */ 0, /* contestationGrade */ 0,
/* contestationGroupSize */ 0L, /* contestationGroupSize */ BigInteger.ZERO,
/* adhesionGrade */ 0, /* adhesionGrade */ 0,
/* adhesionGroupSize */ 0L, /* adhesionGroupSize */ BigInteger.ZERO,
/* secondMedianGrade */ 0, /* secondMedianGrade */ 0,
/* secondMedianGroupSize */ 0L, /* secondMedianGroupSize */ BigInteger.ZERO,
/* secondMedianGroupSign */ 0 /* secondMedianGroupSign */ 0
), ),
Arguments.of( Arguments.of(
/* name */ "Absurd tally of 1 Grade", /* name */ "Approbation",
/* tally */ new Integer[]{ 7 }, /* tally */ new Integer[]{ 31, 72 },
/* medianGrade */ 0, /* medianGrade */ 1,
/* medianGroupSize */ 7L, /* medianGroupSize */ BigInteger.valueOf(72),
/* contestationGrade */ 0, /* contestationGrade */ 0,
/* contestationGroupSize */ 0L, /* contestationGroupSize */ BigInteger.valueOf(31),
/* adhesionGrade */ 0, /* adhesionGrade */ 0,
/* adhesionGroupSize */ 0L, /* adhesionGroupSize */ BigInteger.ZERO,
/* secondMedianGrade */ 0, /* secondMedianGrade */ 0,
/* secondMedianGroupSize */ 0L, /* secondMedianGroupSize */ BigInteger.valueOf(31),
/* secondMedianGroupSign */ 0 /* secondMedianGroupSign */ -1
), ),
Arguments.of( Arguments.of(
/* name */ "Approbation", /* name */ "Equality favors contestation",
/* tally */ new Integer[]{ 31, 72 }, /* tally */ new Integer[]{ 42, 42 },
/* medianGrade */ 1, /* medianGrade */ 0,
/* medianGroupSize */ 72L, /* medianGroupSize */ BigInteger.valueOf(42),
/* contestationGrade */ 0, /* contestationGrade */ 0,
/* contestationGroupSize */ 31L, /* contestationGroupSize */ BigInteger.ZERO,
/* adhesionGrade */ 0, /* adhesionGrade */ 1,
/* adhesionGroupSize */ 0L, /* adhesionGroupSize */ BigInteger.valueOf(42),
/* secondMedianGrade */ 0, /* secondMedianGrade */ 1,
/* secondMedianGroupSize */ 31L, /* secondMedianGroupSize */ BigInteger.valueOf(42),
/* secondMedianGroupSign */ -1 /* secondMedianGroupSign */ 1
), ),
Arguments.of( Arguments.of(
/* name */ "Equality favors contestation", /* name */ "Example with seven grades",
/* tally */ new Integer[]{ 42, 42 }, /* tally */ new Integer[]{ 4, 2, 0, 1, 2, 2, 3 },
/* medianGrade */ 0, /* medianGrade */ 3,
/* medianGroupSize */ 42L, /* medianGroupSize */ BigInteger.valueOf(1),
/* contestationGrade */ 0, /* contestationGrade */ 1,
/* contestationGroupSize */ 0L, /* contestationGroupSize */ BigInteger.valueOf(6),
/* adhesionGrade */ 1, /* adhesionGrade */ 4,
/* adhesionGroupSize */ 42L, /* adhesionGroupSize */ BigInteger.valueOf(7),
/* secondMedianGrade */ 1, /* secondMedianGrade */ 4,
/* secondMedianGroupSize */ 42L, /* secondMedianGroupSize */ BigInteger.valueOf(7),
/* secondMedianGroupSign */ 1 /* secondMedianGroupSign */ 1
), ),
Arguments.of( Arguments.of(
/* name */ "Example with seven grades", /* name */ "Works even if multiple grades are at zero",
/* tally */ new Integer[]{ 4, 2, 0, 1, 2, 2, 3 }, /* tally */ new Integer[]{ 4, 0, 0, 1, 0, 0, 4 },
/* medianGrade */ 3, /* medianGrade */ 3,
/* medianGroupSize */ 1L, /* medianGroupSize */ BigInteger.valueOf(1),
/* contestationGrade */ 1, /* contestationGrade */ 0,
/* contestationGroupSize */ 6L, /* contestationGroupSize */ BigInteger.valueOf(4),
/* adhesionGrade */ 4, /* adhesionGrade */ 6,
/* adhesionGroupSize */ 7L, /* adhesionGroupSize */ BigInteger.valueOf(4),
/* secondMedianGrade */ 4, /* secondMedianGrade */ 0,
/* secondMedianGroupSize */ 7L, /* secondMedianGroupSize */ BigInteger.valueOf(4),
/* secondMedianGroupSign */ 1 /* secondMedianGroupSign */ -1
), ),
Arguments.of( Arguments.of(
/* name */ "Works even if multiple grades are at zero", /* name */ "Weird tally",
/* tally */ new Integer[]{ 4, 0, 0, 1, 0, 0, 4 }, /* tally */ new Integer[]{ 1, 1, 1, 1, 1, 1, 1 },
/* medianGrade */ 3, /* medianGrade */ 3,
/* medianGroupSize */ 1L, /* medianGroupSize */ BigInteger.valueOf(1),
/* contestationGrade */ 0, /* contestationGrade */ 2,
/* contestationGroupSize */ 4L, /* contestationGroupSize */ BigInteger.valueOf(3),
/* adhesionGrade */ 6, /* adhesionGrade */ 4,
/* adhesionGroupSize */ 4L, /* adhesionGroupSize */ BigInteger.valueOf(3),
/* secondMedianGrade */ 0, /* secondMedianGrade */ 2,
/* secondMedianGroupSize */ 4L, /* secondMedianGroupSize */ BigInteger.valueOf(3),
/* secondMedianGroupSign */ -1 /* secondMedianGroupSign */ -1
), )
Arguments.of( );
/* name */ "Weird tally", }
/* tally */ new Integer[]{ 1, 1, 1, 1, 1, 1, 1 },
/* medianGrade */ 3,
/* medianGroupSize */ 1L,
/* contestationGrade */ 2,
/* contestationGroupSize */ 3L,
/* adhesionGrade */ 4,
/* adhesionGroupSize */ 3L,
/* secondMedianGrade */ 2,
/* secondMedianGroupSize */ 3L,
/* secondMedianGroupSign */ -1
)
);
}
} }

Loading…
Cancel
Save