View Javadoc

1   package org.lcsim.spacegeom;
2   import junit.framework.TestCase;
3   
4   // Test the SpaceXform class.
5   
6   //**********************************************************************
7   public class SpaceXformTest extends TestCase
8   {
9   	static class TestXform extends SpaceXform
10  	{	    
11  	    public static int _check = 0;
12  	    public SpaceXform inverse()
13  	    { return this; }
14  	    public SpacePoint apply( SpacePoint spt)
15  	    { _check=1; return spt; }
16  	    public SpacePointVector apply( SpacePointVector svec)
17  	    { _check=2; return svec; }
18  	}
19  	
20      //**********************************************************************
21      boolean debug = false;
22      
23      public void testSpaceXForm()
24      {
25          
26          String name = "SpaceXform";
27          String ok_prefix = name + " test (I): ";
28          String error_prefix = name + " test (E): ";
29          
30          if (debug) System.out.println( ok_prefix
31                  + "------- Testing component " + name + ". -------" );
32          
33          //**********************************************************************
34          
35          if (debug) System.out.println( ok_prefix + "Testing constructor." );
36          TestXform xf = new TestXform();
37          
38          SpacePoint spt1 = new SpacePoint();
39          SpacePointVector svec1 = new SpacePointVector();
40          SpacePath spth1 = new SpacePath();
41          
42          assertTrue(xf._check == 0);
43          SpacePoint spt2 = xf.transform(spt1);
44          assertTrue(xf._check == 1);
45          
46          SpacePointVector svec2 = xf.transform(svec1);
47          assertTrue(xf._check == 2);
48          
49          SpacePointVector spth2 = xf.transform(spth1);
50          assertTrue(xf._check == 2);
51          spt2.x();
52          svec2.getStartPoint().x();
53          spth2.getStartPoint().x();
54          
55          //**********************************************************************
56          
57          if (debug) System.out.println( ok_prefix
58                  + "------------- All tests passed. ------------" );
59          
60      }
61  }