LightVoting
 All Classes Namespaces Files Functions Variables Pages
org.lightvoting.simulation.rule.CMinisumApprovalTest Class Reference

Created by sophie on 01.02.17. More...

Inherits TestCase.

+ Collaboration diagram for org.lightvoting.simulation.rule.CMinisumApprovalTest:

Public Member Functions

 CMinisumApprovalTest (final String p_testName)
 Create the test case. More...
 
void testCMinisumApproval ()
 test Minisum Approval for small instance More...
 
void testCMinisumApproval1 ()
 test MinisumApproval with tie-breaking for small instance More...
 
void testCMinisumApproval3 ()
 test MinisumApproval including tie-break for larger instance More...
 

Static Public Member Functions

static Test suite ()
 Testsuite. More...
 

Detailed Description

Definition at line 42 of file CMinisumApprovalTest.java.

Constructor & Destructor Documentation

org.lightvoting.simulation.rule.CMinisumApprovalTest.CMinisumApprovalTest ( final String  p_testName)
Parameters
p_testNamename of the test case

Definition at line 51 of file CMinisumApprovalTest.java.

52  {
53  super( p_testName );
54  }

Member Function Documentation

static Test org.lightvoting.simulation.rule.CMinisumApprovalTest.suite ( )
static
Returns
the suite of tests being tested

Definition at line 62 of file CMinisumApprovalTest.java.

63  {
64  return new TestSuite( CMinisumApprovalTest.class );
65  }
CMinisumApprovalTest(final String p_testName)
Create the test case.
void org.lightvoting.simulation.rule.CMinisumApprovalTest.testCMinisumApproval ( )

Definition at line 71 of file CMinisumApprovalTest.java.

72  {
73 
74  final CMinisumApproval l_tester = new CMinisumApproval();
75 
76  final List<String> l_testAlternatives = new ArrayList<>();
77  l_testAlternatives.add( "POI1" );
78  l_testAlternatives.add( "POI2" );
79  l_testAlternatives.add( "POI3" );
80 
81  final List<BitVector> l_testVotes = new ArrayList<>();
82 
83  final BitVector l_vote1 = new BitVector( 3 );
84  l_vote1.put( 0, true );
85 
86  final BitVector l_vote2 = new BitVector( 3 );
87 
88  l_vote2.put( 1, true );
89  l_vote2.put( 2, true );
90 
91  final BitVector l_vote3 = new BitVector( 3 );
92 
93  l_vote3.put( 1, true );
94  l_vote3.put( 2, true );
95 
96  l_testVotes.add( l_vote1 );
97  l_testVotes.add( l_vote2 );
98  l_testVotes.add( l_vote3 );
99 
100  final int l_testComSize = 2;
101  final BitVector l_result = l_tester.applyRuleBV( l_testAlternatives, l_testVotes, l_testComSize );
102 
103  assertFalse( l_result.get( 0 ) );
104  assertTrue( l_result.get( 1 ) );
105  assertTrue( l_result.get( 2 ) );
106  }
void org.lightvoting.simulation.rule.CMinisumApprovalTest.testCMinisumApproval1 ( )

Definition at line 112 of file CMinisumApprovalTest.java.

113  {
114 
115  final CMinisumApproval l_tester = new CMinisumApproval();
116 
117  final List<String> l_testAlternatives = new ArrayList<>();
118  l_testAlternatives.add( "POI1" );
119  l_testAlternatives.add( "POI2" );
120  l_testAlternatives.add( "POI3" );
121 
122  final List<BitVector> l_testVotes = new ArrayList<>();
123  final BitVector l_vote1 = new BitVector( 3 );
124  l_vote1.put( 0, true );
125  l_vote1.put( 2, true );
126 
127  final BitVector l_vote2 = new BitVector( 3 );
128  l_vote2.put( 1, true );
129 
130  final BitVector l_vote3 = new BitVector( 3 );
131 
132  l_vote3.put( 0, true );
133  l_vote3.put( 1, true );
134  l_vote3.put( 2, true );
135 
136  l_testVotes.add( l_vote1 );
137  l_testVotes.add( l_vote2 );
138  l_testVotes.add( l_vote3 );
139 
140  final int l_testComSize = 2;
141  final BitVector l_result = l_tester.applyRuleBV( l_testAlternatives, l_testVotes, l_testComSize );
142  assertTrue( l_result.get( 0 ) );
143  assertTrue( l_result.get( 1 ) );
144  assertFalse( l_result.get( 2 ) );
145  }
void org.lightvoting.simulation.rule.CMinisumApprovalTest.testCMinisumApproval3 ( )

Definition at line 151 of file CMinisumApprovalTest.java.

152  {
153 
154  final CMinisumApproval l_tester = new CMinisumApproval();
155 
156  List<String> l_testAlternatives;
157  l_testAlternatives = new ArrayList<String>();
158  l_testAlternatives.add( "POI1" );
159  l_testAlternatives.add( "POI2" );
160  l_testAlternatives.add( "POI3" );
161  l_testAlternatives.add( "POI4" );
162  l_testAlternatives.add( "POI5" );
163  l_testAlternatives.add( "POI6" );
164 
165  final List<BitVector> l_testVotes = new ArrayList<>( );
166  final BitVector l_vote1 = new BitVector( 6 );
167 
168  l_vote1.put( 0, true );
169  l_vote1.put( 2, true );
170  l_vote1.put( 3, true );
171  l_vote1.put( 5, true );
172 
173  final BitVector l_vote2 = new BitVector( 6 );
174 
175  l_vote2.put( 0, true );
176  l_vote2.put( 2, true );
177  l_vote2.put( 3, true );
178  l_vote2.put( 5, true );
179 
180  final BitVector l_vote3 = new BitVector( 6 );
181 
182  l_vote3.put( 0, true );
183  l_vote3.put( 2, true );
184  l_vote3.put( 3, true );
185  l_vote3.put( 5, true );
186 
187  final BitVector l_vote4 = new BitVector( 6 );
188 
189  l_vote4.put( 2, true );
190 
191  l_testVotes.add( l_vote1 );
192  l_testVotes.add( l_vote2 );
193  l_testVotes.add( l_vote3 );
194  l_testVotes.add( l_vote4 );
195 
196  final int l_testComSize = 3;
197  final BitVector l_result = l_tester.applyRuleBV( l_testAlternatives, l_testVotes, l_testComSize );
198  assertTrue( l_result.get( 0 ) );
199  assertFalse( l_result.get( 1 ) );
200  assertTrue( l_result.get( 2 ) );
201  assertTrue( l_result.get( 3 ) );
202  assertFalse( l_result.get( 4 ) );
203  assertFalse( l_result.get( 5 ) );
204  }