Changeset 209


Ignore:
Timestamp:
Oct 26, 2010, 6:19:27 AM (14 years ago)
Author:
Rick van der Zwet
Message:

Some more usefull tests and debugging

Location:
liacs/TOOS/assignment1
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • liacs/TOOS/assignment1/build.xml

    r208 r209  
    2525      <mkdir dir="${classes.dir}"/>
    2626      <javac srcdir="${src.dir}" destdir="${classes.dir}"
    27         includeAntRuntime="${javac.includeAntRuntime}" classpathref="classpath">
    28 
     27        includeAntRuntime="${javac.includeAntRuntime}"
     28        classpathref="classpath"
     29        debug="true">
    2930        <compilerarg value="-Xlint:unchecked" />
    3031      </javac>
     
    5253  </target>
    5354
    54   <target name="junit" depends="jar">
     55  <target name="junit" depends="clean, jar">
    5556    <mkdir dir="${report.dir}" />
    5657    <junit printsummary="no">
  • liacs/TOOS/assignment1/src/Census.java

    r206 r209  
    1313  static Logger logger = Logger.getLogger(Census.class);
    1414  public static void main(String[] args) {
    15     BasicConfigurator.configure();
    16    
    17     Census census = new Census();
    18 
    19     HashSet<Voter> voters = new HashSet<Voter>();
    20     voters.add(new Voter(true));
    21     voters.add(new Voter(true));
    22     Voter duplicate  = new Voter(true);
    23     voters.add(duplicate);
    24     voters.add(duplicate);
    25     //voters.add(new Voter());
    26    
    27     logger.info(census.census(voters));
    2815  }
    2916  /**
     
    3522   * @return boolean with conjuction of voters or null on error.
    3623   */
    37   public Boolean census(HashSet<Voter> voters) {
     24  public static Boolean census(HashSet<Voter> voters) {
     25
    3826    /* Nobody likes voting on Tuesday don't they? */
    3927    Calendar rightNow = Calendar.getInstance();
    40     if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY) {
     28    if (rightNow.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY) {
    4129      return false;
    4230    }
     
    4735      /* Some vote is not set correctly or of wrong return value */
    4836      if (v.getVote() == null || (!(v.getVote() instanceof Boolean))) {
    49         return false;
     37        logger.debug("Invalid type");
     38        return null;
    5039      }
    5140
  • liacs/TOOS/assignment1/src/CensusTest.java

    r208 r209  
    1 package nl.rickvanderzwet.toos.assignment1;
    2 
    31import java.util.Calendar;
    42import java.util.HashSet;
     
    119
    1210    public void testEmptyVoteList() {
     11      HashSet<Voter> v = null;
    1312      Census c = new Census();
    14       assertTrue(c.census(null).equals(null));   
     13      assertTrue(c.census(v).equals(null));   
    1514    }
    16    
    17     public void testNoVote() {
    18         fail("An error message");
     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));   
    1925    }
    20    
     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    }
    2137}
Note: See TracChangeset for help on using the changeset viewer.