View Javadoc

1   /*
2    * PropStat_Test.java
3    *
4    * Created on July 24, 2007, 12:03 PM
5    *
6    * $Id: PropStat_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfbase;
10  
11  import junit.framework.TestCase;
12  import org.lcsim.recon.tracking.trfutil.Assert;
13  
14  /**
15   *
16   * @author Norman Graf
17   */
18  public class PropStat_Test extends TestCase
19  {
20      private boolean debug;
21      /** Creates a new instance of PropStat_Test */
22      public void testPropStat()
23      {
24          String ok_prefix = "PropStat (I): ";
25          String error_prefix = "PropStat test (E): ";
26          
27          if(debug) System.out.println( ok_prefix
28                  + "-------- Testing component PropStat. --------" );
29          
30          //********************************************************************
31          
32          if(debug) System.out.println( ok_prefix + "Test constructor produces failed propagation."
33                  );
34          {
35              PropStat pst = new PropStat();
36              if(debug) System.out.println( pst );
37              Assert.assertTrue( ! pst.success() );
38              Assert.assertTrue( ! pst.forward() );
39              Assert.assertTrue( ! pst.backward() );
40              Assert.assertTrue( ! pst.same() );
41          }
42                  
43                  //********************************************************************
44                  
45                  if(debug) System.out.println( ok_prefix + "Test forward propagation." );
46                  {
47                      PropStat pst = new PropStat();
48                      double dist = 123.56;
49                      pst.setPathDistance(dist);
50                      if(debug) System.out.println( pst );
51                      Assert.assertTrue(   pst.success() );
52                      Assert.assertTrue(   pst.forward() );
53                      Assert.assertTrue( ! pst.backward() );
54                      Assert.assertTrue( ! pst.same() );
55                      Assert.assertTrue( pst.pathDistance() == dist );
56                  }
57                  
58                  //********************************************************************
59                  
60                  if(debug) System.out.println( ok_prefix + "Test backward propagation." );
61                  {
62                      PropStat pst = new PropStat();
63                      double dist = -123.56;
64                      pst.setPathDistance(dist);
65                      if(debug) System.out.println( pst );
66                      Assert.assertTrue(   pst.success() );
67                      Assert.assertTrue( ! pst.forward() );
68                      Assert.assertTrue(   pst.backward() );
69                      Assert.assertTrue( ! pst.same() );
70                      Assert.assertTrue( pst.pathDistance() == dist );
71                  }
72                  
73                  //********************************************************************
74                  
75                  if(debug) System.out.println( ok_prefix + "Test same propagation." );
76                  {
77                      PropStat pst = new PropStat();
78                      pst.setSame();
79                      double dist = 0.0;
80                      pst.setPathDistance(dist);
81                      if(debug) System.out.println( pst );
82                      Assert.assertTrue(   pst.success() );
83                      Assert.assertTrue( ! pst.forward() );
84                      Assert.assertTrue( ! pst.backward() );
85                      Assert.assertTrue(   pst.same() );
86                      Assert.assertTrue( pst.pathDistance() == dist );
87                  }
88                  
89                  //********************************************************************
90                  
91                  if(debug) System.out.println( ok_prefix
92                          + "------------- All tests passed. -------------" );
93                  
94                  
95                  //********************************************************************        
96      }
97      
98  }