001 package org.hackystat.sensor.ant.vcs; 002 003 import junit.framework.TestCase; 004 005 /** 006 * Test case for <code>GenericSizeCounter</code>. 007 * 008 * @author Qin ZHANG 009 * @version $Id$ 010 */ 011 public class TestGenericSizeCounter extends TestCase { 012 013 /** 014 * Tests with strings. 015 * @throws Exception If test fails. 016 */ 017 public void test1() throws Exception { 018 String[] content = new String[] { " line1 ", " ", "line2", " \t line3 ", null, " \t ", 019 "\t" }; 020 GenericSizeCounter size = new GenericSizeCounter(content); 021 assertEquals("The total amount of lines is incorrect.", 6, size.getNumOfTotalLines()); 022 assertEquals("The total non-empty lines is incorrect.", 3, size.getNumOfNonEmptyLines()); 023 } 024 025 /** 026 * Tests with objects. 027 * @throws Exception If test fails. 028 */ 029 public void test2() throws Exception { 030 Object[] content = new Object[] { new Object(), null, new Object() }; 031 GenericSizeCounter size = new GenericSizeCounter(content); 032 assertEquals("The total amount of lines is incorrect.", 2, size.getNumOfTotalLines()); 033 assertEquals("The total non-empty lines is incorrect.", 2, size.getNumOfNonEmptyLines()); 034 } 035 }