KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > gov > nasa > jpf > mc > TestRandomJPF


1 //
2
// Copyright (C) 2005 United States Government as represented by the
3
// Administrator of the National Aeronautics and Space Administration
4
// (NASA). All Rights Reserved.
5
//
6
// This software is distributed under the NASA Open Source Agreement
7
// (NOSA), version 1.3. The NOSA has been approved by the Open Source
8
// Initiative. See the file NOSA-1.3-JPF at the top of the distribution
9
// directory tree for the complete NOSA document.
10
//
11
// THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY
12
// KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT
13
// LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO
14
// SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR
15
// A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT
16
// THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT
17
// DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE.
18
//
19
package gov.nasa.jpf.mc;
20
21 import gov.nasa.jpf.jvm.TestJPF;
22 import gov.nasa.jpf.jvm.Verify;
23
24 import junit.framework.TestSuite;
25
26 import junit.textui.TestRunner;
27
28
29 /**
30  * JPF driver of gov.nasa.jpf.jvm.Verify test for nondeterministic
31  * data initialization
32  */

33 public class TestRandomJPF extends TestJPF {
34   static String JavaDoc testClass = "gov.nasa.jpf.mc.TestRandom";
35
36   public TestRandomJPF (String JavaDoc name) {
37     super(name);
38   }
39
40   public static void main (String JavaDoc[] args) {
41     TestRunner.run(suite());
42   }
43
44   public static TestSuite suite () {
45     return new TestSuite(TestRandomJPF.class);
46   }
47
48   /**************************** tests **********************************/
49   public void testRandom () {
50     String JavaDoc[] args = { testClass, "testRandom", "3" };
51     
52     Verify.resetCounter(0);
53     
54     runJPFnoException(args);
55
56     if (Verify.getCounter(0) != 4) {
57       fail("wrong number of backtracks");
58     }
59   }
60   
61   public void testRandomBFS () {
62     String JavaDoc[] args = { "+search.class=gov.nasa.jpf.search.heuristic.HeuristicSearch",
63         "+search.heuristic.class=gov.nasa.jpf.search.heuristic.BFSHeuristic", testClass };
64
65     Verify.resetCounter(0);
66
67     runJPFnoException(args);
68
69     if (Verify.getCounter(0) != 4) {
70 System.out.println("#### " + Verify.getCounter(0));
71       fail("wrong number of backtracks");
72     }
73   }
74 }
75
Popular Tags