Skip to content
Snippets Groups Projects
Commit b1b0da05 authored by Antoine Kryus's avatar Antoine Kryus
Browse files

add copeland test

parent 5a3540ac
No related branches found
No related tags found
No related merge requests found
......@@ -121,6 +121,42 @@ func TestApprovalSCF(t *testing.T) {
}
}
func TestCopelandSWF(t *testing.T) {
prefs := [][]Alternative{
{3, 1, 2}, // (1) = -1 -1 = -2 ; (2) = +1 -1 = 0 ; (3) = 2
{2, 1, 3},
{3, 2, 1},
}
res, _ := CopelandSWF(prefs)
if res[1] != -2 {
t.Errorf("error, result for 1 should be -2, %d computed", res[1])
}
if res[2] != 0 {
t.Errorf("error, result for 2 should be 0, %d computed", res[2])
}
if res[3] != 2 {
t.Errorf("error, result for 3 should be 2, %d computed", res[3])
}
}
func TestCopelandSCF(t *testing.T) {
prefs := [][]Alternative{
{3, 1, 2},
{2, 1, 3},
{3, 2, 1},
}
res, err := CopelandSCF(prefs)
if err != nil {
t.Error(err)
}
if len(res) != 1 || res[0] != 3 {
t.Errorf("error, 3 should be the only best Alternative")
}
}
func TestCondorcetWinner(t *testing.T) {
prefs1 := [][]Alternative{
{1, 2, 3},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment