From ba46d3db50526b6fc96ca77abeb408906889c42d Mon Sep 17 00:00:00 2001 From: domi41 Date: Sun, 9 May 2021 20:14:21 +0200 Subject: [PATCH] fix: add the forgotten test file Now the test-suite should pass again on master. --- .../mj/ProposalTallyAnalysisTest.java | 236 +++++++++--------- 1 file changed, 112 insertions(+), 124 deletions(-) diff --git a/src/test/java/fr/mieuxvoter/mj/ProposalTallyAnalysisTest.java b/src/test/java/fr/mieuxvoter/mj/ProposalTallyAnalysisTest.java index e7890f6..f98df10 100644 --- a/src/test/java/fr/mieuxvoter/mj/ProposalTallyAnalysisTest.java +++ b/src/test/java/fr/mieuxvoter/mj/ProposalTallyAnalysisTest.java @@ -2,6 +2,7 @@ package fr.mieuxvoter.mj; import static org.junit.jupiter.api.Assertions.*; +import java.math.BigInteger; import java.util.stream.Stream; import org.junit.jupiter.api.DisplayName; @@ -21,13 +22,13 @@ class ProposalTallyAnalysisTest { String testName, Integer[] rawTally, Integer medianGrade, - Long medianGroupSize, + BigInteger medianGroupSize, Integer contestationGrade, - Long contestationGroupSize, + BigInteger contestationGroupSize, Integer adhesionGrade, - Long adhesionGroupSize, + BigInteger adhesionGroupSize, Integer secondMedianGrade, - Long secondMedianGroupSize, + BigInteger secondMedianGroupSize, Integer secondMedianGroupSign ) { ProposalTally tally = new ProposalTally(rawTally); @@ -44,124 +45,111 @@ class ProposalTallyAnalysisTest { } protected static Stream testProvider() { - return Stream.of( -// Arguments.of( -// /* name */ "Void tallies yield ???", // perhaps raise ? later -// /* tally */ new Integer[]{}, -// /* medianGrade */ 0, -// /* medianGroupSize */ 0, -// /* contestationGrade */ 0, -// /* contestationGroupSize */ 0, -// /* adhesionGrade */ 0, -// /* adhesionGroupSize */ 0, -// /* secondMedianGrade */ 0, -// /* secondMedianGroupSize */ 0, -// /* secondMedianGroupSign */ 0 -// ), - Arguments.of( - /* name */ "Very empty tallies yield zeroes", - /* tally */ new Integer[]{ 0 }, - /* medianGrade */ 0, - /* medianGroupSize */ 0L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 0L, - /* adhesionGrade */ 0, - /* adhesionGroupSize */ 0L, - /* secondMedianGrade */ 0, - /* secondMedianGroupSize */ 0L, - /* secondMedianGroupSign */ 0 - ), - Arguments.of( - /* name */ "Empty tallies yield zeroes", - /* tally */ new Integer[]{ 0, 0, 0, 0 }, - /* medianGrade */ 0, - /* medianGroupSize */ 0L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 0L, - /* adhesionGrade */ 0, - /* adhesionGroupSize */ 0L, - /* secondMedianGrade */ 0, - /* secondMedianGroupSize */ 0L, - /* secondMedianGroupSign */ 0 - ), - Arguments.of( - /* name */ "Absurd tally of 1 Grade", - /* tally */ new Integer[]{ 7 }, - /* medianGrade */ 0, - /* medianGroupSize */ 7L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 0L, - /* adhesionGrade */ 0, - /* adhesionGroupSize */ 0L, - /* secondMedianGrade */ 0, - /* secondMedianGroupSize */ 0L, - /* secondMedianGroupSign */ 0 - ), - Arguments.of( - /* name */ "Approbation", - /* tally */ new Integer[]{ 31, 72 }, - /* medianGrade */ 1, - /* medianGroupSize */ 72L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 31L, - /* adhesionGrade */ 0, - /* adhesionGroupSize */ 0L, - /* secondMedianGrade */ 0, - /* secondMedianGroupSize */ 31L, - /* secondMedianGroupSign */ -1 - ), - Arguments.of( - /* name */ "Equality favors contestation", - /* tally */ new Integer[]{ 42, 42 }, - /* medianGrade */ 0, - /* medianGroupSize */ 42L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 0L, - /* adhesionGrade */ 1, - /* adhesionGroupSize */ 42L, - /* secondMedianGrade */ 1, - /* secondMedianGroupSize */ 42L, - /* secondMedianGroupSign */ 1 - ), - Arguments.of( - /* name */ "Example with seven grades", - /* tally */ new Integer[]{ 4, 2, 0, 1, 2, 2, 3 }, - /* medianGrade */ 3, - /* medianGroupSize */ 1L, - /* contestationGrade */ 1, - /* contestationGroupSize */ 6L, - /* adhesionGrade */ 4, - /* adhesionGroupSize */ 7L, - /* secondMedianGrade */ 4, - /* secondMedianGroupSize */ 7L, - /* secondMedianGroupSign */ 1 - ), - Arguments.of( - /* name */ "Works even if multiple grades are at zero", - /* tally */ new Integer[]{ 4, 0, 0, 1, 0, 0, 4 }, - /* medianGrade */ 3, - /* medianGroupSize */ 1L, - /* contestationGrade */ 0, - /* contestationGroupSize */ 4L, - /* adhesionGrade */ 6, - /* adhesionGroupSize */ 4L, - /* secondMedianGrade */ 0, - /* secondMedianGroupSize */ 4L, - /* 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 - ) - ); - } + return Stream.of( + Arguments.of( + /* name */ "Very empty tallies yield zeroes", + /* tally */ new Integer[]{ 0 }, + /* medianGrade */ 0, + /* medianGroupSize */ BigInteger.ZERO, + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.ZERO, + /* adhesionGrade */ 0, + /* adhesionGroupSize */ BigInteger.ZERO, + /* secondMedianGrade */ 0, + /* secondMedianGroupSize */ BigInteger.ZERO, + /* secondMedianGroupSign */ 0 + ), + Arguments.of( + /* name */ "Empty tallies yield zeroes", + /* tally */ new Integer[]{ 0, 0, 0, 0 }, + /* medianGrade */ 0, + /* medianGroupSize */ BigInteger.ZERO, + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.ZERO, + /* adhesionGrade */ 0, + /* adhesionGroupSize */ BigInteger.ZERO, + /* secondMedianGrade */ 0, + /* secondMedianGroupSize */ BigInteger.ZERO, + /* secondMedianGroupSign */ 0 + ), + Arguments.of( + /* name */ "Absurd tally of 1 Grade", + /* tally */ new Integer[]{ 7 }, + /* medianGrade */ 0, + /* medianGroupSize */ BigInteger.valueOf(7), + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.ZERO, + /* adhesionGrade */ 0, + /* adhesionGroupSize */ BigInteger.ZERO, + /* secondMedianGrade */ 0, + /* secondMedianGroupSize */ BigInteger.ZERO, + /* secondMedianGroupSign */ 0 + ), + Arguments.of( + /* name */ "Approbation", + /* tally */ new Integer[]{ 31, 72 }, + /* medianGrade */ 1, + /* medianGroupSize */ BigInteger.valueOf(72), + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.valueOf(31), + /* adhesionGrade */ 0, + /* adhesionGroupSize */ BigInteger.ZERO, + /* secondMedianGrade */ 0, + /* secondMedianGroupSize */ BigInteger.valueOf(31), + /* secondMedianGroupSign */ -1 + ), + Arguments.of( + /* name */ "Equality favors contestation", + /* tally */ new Integer[]{ 42, 42 }, + /* medianGrade */ 0, + /* medianGroupSize */ BigInteger.valueOf(42), + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.ZERO, + /* adhesionGrade */ 1, + /* adhesionGroupSize */ BigInteger.valueOf(42), + /* secondMedianGrade */ 1, + /* secondMedianGroupSize */ BigInteger.valueOf(42), + /* secondMedianGroupSign */ 1 + ), + Arguments.of( + /* name */ "Example with seven grades", + /* tally */ new Integer[]{ 4, 2, 0, 1, 2, 2, 3 }, + /* medianGrade */ 3, + /* medianGroupSize */ BigInteger.valueOf(1), + /* contestationGrade */ 1, + /* contestationGroupSize */ BigInteger.valueOf(6), + /* adhesionGrade */ 4, + /* adhesionGroupSize */ BigInteger.valueOf(7), + /* secondMedianGrade */ 4, + /* secondMedianGroupSize */ BigInteger.valueOf(7), + /* secondMedianGroupSign */ 1 + ), + Arguments.of( + /* name */ "Works even if multiple grades are at zero", + /* tally */ new Integer[]{ 4, 0, 0, 1, 0, 0, 4 }, + /* medianGrade */ 3, + /* medianGroupSize */ BigInteger.valueOf(1), + /* contestationGrade */ 0, + /* contestationGroupSize */ BigInteger.valueOf(4), + /* adhesionGrade */ 6, + /* adhesionGroupSize */ BigInteger.valueOf(4), + /* secondMedianGrade */ 0, + /* secondMedianGroupSize */ BigInteger.valueOf(4), + /* secondMedianGroupSign */ -1 + ), + Arguments.of( + /* name */ "Weird tally", + /* tally */ new Integer[]{ 1, 1, 1, 1, 1, 1, 1 }, + /* medianGrade */ 3, + /* medianGroupSize */ BigInteger.valueOf(1), + /* contestationGrade */ 2, + /* contestationGroupSize */ BigInteger.valueOf(3), + /* adhesionGrade */ 4, + /* adhesionGroupSize */ BigInteger.valueOf(3), + /* secondMedianGrade */ 2, + /* secondMedianGroupSize */ BigInteger.valueOf(3), + /* secondMedianGroupSign */ -1 + ) + ); + } }