|
|
|
@ -7,7 +7,6 @@ import (
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestReadmeDemo(t *testing.T) {
|
|
|
|
|
|
|
|
|
|
poll := &PollTally{
|
|
|
|
|
AmountOfJudges: 10,
|
|
|
|
|
Proposals: []*ProposalTally{
|
|
|
|
@ -29,3 +28,28 @@ func TestReadmeDemo(t *testing.T) {
|
|
|
|
|
assert.Equal(t, 3, result.Proposals[3].Rank, "Rank of proposal D")
|
|
|
|
|
assert.Equal(t, 4, result.Proposals[4].Rank, "Rank of proposal E")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestNoProposals(t *testing.T) {
|
|
|
|
|
poll := &PollTally{
|
|
|
|
|
AmountOfJudges: 10,
|
|
|
|
|
Proposals: []*ProposalTally{},
|
|
|
|
|
}
|
|
|
|
|
deliberator := &MajorityJudgment{}
|
|
|
|
|
result, err := deliberator.Deliberate(poll)
|
|
|
|
|
assert.NoError(t, err, "Deliberation should succeed")
|
|
|
|
|
assert.Len(t, result.Proposals, len(poll.Proposals), "There should be as many results as there are tallies.")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func TestMishapedTally(t *testing.T) {
|
|
|
|
|
poll := &PollTally{
|
|
|
|
|
AmountOfJudges: 10,
|
|
|
|
|
Proposals: []*ProposalTally{
|
|
|
|
|
{Tally: []uint64{2, 2, 2, 2, 2}},
|
|
|
|
|
{Tally: []uint64{2, 2, 2, 2}},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
deliberator := &MajorityJudgment{}
|
|
|
|
|
result, err := deliberator.Deliberate(poll)
|
|
|
|
|
assert.Error(t, err, "Deliberation should fail")
|
|
|
|
|
assert.Nil(t, result, "Deliberation result should be nil")
|
|
|
|
|
}
|
|
|
|
|