Example usage for org.apache.commons.math3.fraction BigFraction ONE_THIRD

List of usage examples for org.apache.commons.math3.fraction BigFraction ONE_THIRD

Introduction

In this page you can find the example usage for org.apache.commons.math3.fraction BigFraction ONE_THIRD.

Prototype

BigFraction ONE_THIRD

To view the source code for org.apache.commons.math3.fraction BigFraction ONE_THIRD.

Click Source Link

Document

A fraction representing "1/3".

Usage

From source file:info.gehrels.voting.singleTransferableVote.VoteStateTest.java

@Test
public void returnsNewVoteStateWithSameValuesButUpdatedVoteWeight() {
    Ballot<Candidate> ballot = TestUtils.createBallot("AB", ELECTION);
    VoteState<Candidate> voteState = VoteState.forBallotAndElection(ballot, ELECTION).get();

    VoteState<Candidate> newVoteState = voteState.withVoteWeight(BigFraction.ONE_THIRD);

    assertThat(newVoteState, is(not(sameInstance(voteState))));
    assertThat(newVoteState.getPreferredCandidate(), is(equalTo(voteState.getPreferredCandidate())));
    assertThat(newVoteState.isInvalid(), is(false));
    assertThat(newVoteState.isNoVote(), is(false));
    assertThat(newVoteState.getVoteWeight(), is(not(equalTo(voteState.getVoteWeight()))));
    assertThat(newVoteState.getVoteWeight(), is(equalTo(BigFraction.ONE_THIRD)));
}