View Javadoc

1   /*
2    * Pair_Test.java
3    *
4    * Created on July 24, 2007, 11:37 AM
5    *
6    * $Id: Pair_Test.java,v 1.1.1.1 2010/04/08 20:38:00 jeremy Exp $
7    */
8   
9   package org.lcsim.recon.tracking.trfutil;
10  
11  import junit.framework.TestCase;
12  
13  /**
14   *
15   * @author Norman Graf
16   */
17  public class Pair_Test extends TestCase
18  {
19      private boolean debug;
20      /** Creates a new instance of Pair_Test */
21      public void testPair()
22      {
23          String component = "Pair";
24          String ok_prefix = component + " (I): ";
25          String error_prefix = component + " test (E): ";
26          
27          if(debug) System.out.println("-------- Testing component " + component
28                  + ". --------" );
29          
30          //********************************************************************
31          
32          if(debug) System.out.println("Testing Constructor");
33          
34          Integer int1 = new Integer(1);
35          Integer int2 = new Integer(2);
36          
37          Pair pair = new Pair(int1, int2);
38          
39          if(debug) System.out.println("pair= "+pair);
40          
41          Assert.assertTrue(pair.first().equals(int1));
42          Assert.assertTrue(pair.second().equals(int2));
43          
44          Object obj1 = new Integer(1);
45          Object obj2 = new Integer(2);
46          Assert.assertTrue(obj1!=int1);
47          Assert.assertTrue(obj2!=int2);
48          Pair pair2 = new Pair(obj1, obj2);
49          Assert.assertTrue(pair.equals(pair2));
50          
51          Integer int3 = new Integer(3);
52          Pair pair3 = new Pair(int1, int3);
53          Assert.assertTrue(pair.notEquals(pair3));
54          
55          //********************************************************************
56          
57          if(debug) System.out.println( "------------- All tests passed. -------------" );
58          
59          
60          //********************************************************************
61      }
62      
63  }