Last change
on this file since 211 was 210, checked in by Rick van der Zwet, 14 years ago |
Some more test cases and a working program. Let's go to the University.
|
File size:
1.6 KB
|
Rev | Line | |
---|
[208] | 1 | import java.util.Calendar;
|
---|
| 2 | import java.util.HashSet;
|
---|
| 3 | import java.util.Enumeration;
|
---|
| 4 |
|
---|
| 5 | import nl.rickvanderzwet.toos.assignment1.Voter;
|
---|
| 6 | import nl.rickvanderzwet.toos.assignment1.Census;
|
---|
| 7 |
|
---|
[207] | 8 | public class CensusTest extends junit.framework.TestCase {
|
---|
| 9 |
|
---|
[208] | 10 | public void testEmptyVoteList() {
|
---|
[209] | 11 | HashSet<Voter> v = null;
|
---|
[208] | 12 | Census c = new Census();
|
---|
[210] | 13 | assertNull(c.census(v));
|
---|
[207] | 14 | }
|
---|
[209] | 15 |
|
---|
| 16 | public void testAllPositiveVote() {
|
---|
| 17 | HashSet<Voter> v = new HashSet<Voter>();
|
---|
| 18 | v.add(new Voter(true));
|
---|
| 19 | v.add(new Voter(true));
|
---|
| 20 | v.add(new Voter(true));
|
---|
| 21 | v.add(new Voter(true));
|
---|
| 22 |
|
---|
| 23 | Census c = new Census();
|
---|
| 24 | assertTrue(c.census(v));
|
---|
[207] | 25 | }
|
---|
[209] | 26 |
|
---|
| 27 | public void testNegativeVote() {
|
---|
| 28 | HashSet<Voter> v = new HashSet<Voter>();
|
---|
| 29 | v.add(new Voter(true));
|
---|
| 30 | v.add(new Voter(true));
|
---|
| 31 | v.add(new Voter(false));
|
---|
| 32 | v.add(new Voter(true));
|
---|
| 33 |
|
---|
| 34 | Census c = new Census();
|
---|
| 35 | assertFalse(c.census(v));
|
---|
| 36 | }
|
---|
[210] | 37 |
|
---|
| 38 | public void testInvalidVoter() {
|
---|
| 39 | HashSet<Voter> v = new HashSet<Voter>();
|
---|
| 40 | v.add(new Voter(true));
|
---|
| 41 | v.add(new Voter(true));
|
---|
| 42 | v.add(new Voter(false));
|
---|
| 43 | v.add(null);
|
---|
| 44 |
|
---|
| 45 | Census c = new Census();
|
---|
| 46 | assertNull(c.census(v));
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | public void testDuplicateVote() {
|
---|
| 50 | HashSet<Voter> v = new HashSet<Voter>();
|
---|
| 51 | Voter d = new Voter(true);
|
---|
| 52 | assertTrue(v.add(d));
|
---|
| 53 | assertFalse(v.add(d));
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public void testUnusedVote() {
|
---|
| 57 | HashSet<Voter> v = new HashSet<Voter>();
|
---|
| 58 | v.add(new Voter(true));
|
---|
| 59 | v.add(new Voter(true));
|
---|
| 60 | v.add(new Voter(false));
|
---|
| 61 | v.add(new Voter());
|
---|
| 62 |
|
---|
| 63 | Census c = new Census();
|
---|
| 64 | assertNull(c.census(v));
|
---|
| 65 | }
|
---|
[207] | 66 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.