KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hanseltest > TestSwitchBug


1 package org.hanseltest;
2
3 import junit.framework.TestCase;
4 import junit.framework.TestResult;
5
6 import org.hansel.CoverageDecorator;
7
8 /**
9  * This TestCase tests for a bug when using the jikes compiler and switch statements.
10  * The precompiled CoverSwitchBug class is contained in the "classes" directory.
11  */

12 public class TestSwitchBug extends TestCase {
13     /** Class to be covered by this test. */
14     private static final Class JavaDoc[] COVERED = {CoverSwitchBug.class};
15     
16     public void testBug() {
17         CoverageDecorator cd = new CoverageDecorator(FullCoverage.class,
18                                                      COVERED);
19
20         TestResult result = new TestResult();
21         cd.run(result);
22
23         assertEquals(0, result.failureCount());
24     }
25     
26
27     public static class FullCoverage extends TestCase {
28
29         public void testCase() {
30             CoverSwitchBug coverSwitchbug = new CoverSwitchBug();
31             coverSwitchbug.aCase(-1);
32             coverSwitchbug.aCase(1);
33             coverSwitchbug.aCase(2);
34         }
35     }
36
37 }
38
Popular Tags