KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > example > simple > SimpleTest


1 /**
2  * Cobertura - http://cobertura.sourceforge.net/
3  *
4  * Copyright (C) 2003 jcoverage ltd.
5  * Copyright (C) 2005 Mark Doliner <thekingant@users.sourceforge.net>
6  *
7  * Cobertura is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11  *
12  * Cobertura is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with Cobertura; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20  * USA
21  */

22
23 package com.example.simple;
24
25 import java.util.Collection JavaDoc;
26 import java.util.LinkedList JavaDoc;
27
28 import junit.framework.TestCase;
29
30 public class SimpleTest extends TestCase
31 {
32
33     final Simple simple = new Simple();
34
35     public SimpleTest(String JavaDoc nm)
36     {
37         super(nm);
38     }
39
40     public void testSquare()
41     {
42         assertEquals(1, simple.square(1));
43         assertEquals(1, simple.square(-1));
44     }
45
46     public void testF()
47     {
48         assertEquals(1, simple.f(-1));
49         assertEquals(12, simple.f(6));
50     }
51
52     public void testSum()
53     {
54         Collection JavaDoc c = new LinkedList JavaDoc();
55         c.add(new Integer JavaDoc(3));
56         c.add(new Integer JavaDoc(5));
57         c.add(new Integer JavaDoc(8));
58         assertEquals(16, simple.sum(c));
59     }
60 }
Popular Tags