1 /* 2 * McCluster_Test.java 3 * 4 * Created on July 24, 2007, 12:14 PM 5 * 6 * $Id: McCluster_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 java.util.ArrayList; 12 import java.util.List; 13 import junit.framework.TestCase; 14 import org.lcsim.recon.tracking.trfutil.Assert; 15 16 /** 17 * 18 * @author Norman Graf 19 */ 20 public class McCluster_Test extends TestCase 21 { 22 private boolean debug; 23 /** Creates a new instance of McCluster_Test */ 24 public void testMcCluster() 25 { 26 String component = "McCluster"; 27 String ok_prefix = component + " (I): "; 28 String error_prefix = component + " test (E): "; 29 30 if(debug) System.out.println("-------- Testing component " + component 31 + ". --------" ); 32 33 //******************************************************************** 34 35 if(debug) System.out.println("Check MC ID's." ); 36 SurfTest stest = new SurfTest(3); 37 int[] ids = {1, 22, 333}; 38 39 Cluster pclu1 = new McClusterTest(stest,ids); 40 { 41 List oids = pclu1.mcIds(); 42 int[] oida = pclu1.mcIdArray(); 43 // Assert.assertTrue( oids.size() == 3 ); 44 Assert.assertTrue( oida.length == 3 ); 45 // Assert.assertTrue( ((Integer) oids.get(0)).valueOf() == 1 ); 46 Assert.assertTrue( oida[0] == 1 ); 47 Assert.assertTrue( oida[1] == 22 ); 48 Assert.assertTrue( oida[2] == 333 ); 49 } 50 51 if(debug) System.out.println("Constructor from list of Ids"); 52 List mcids = new ArrayList(); 53 for(int i = 0; i<ids.length; ++i) 54 { 55 mcids.add(new Integer( ids[i]) ); 56 } 57 Cluster clus2 = new McClusterTest(stest, mcids); 58 int[] tstids = clus2.mcIdArray(); 59 Assert.assertTrue( tstids.length == 3 ); 60 Assert.assertTrue( tstids[0] == 1 ); 61 Assert.assertTrue( tstids[1] == 22 ); 62 Assert.assertTrue( tstids[2] == 333 ); 63 64 if(debug) System.out.println("Constructor from single Id"); 65 int mcid = 137; 66 Cluster clus3 = new McClusterTest(stest, mcid); 67 tstids = clus3.mcIdArray(); 68 Assert.assertTrue( tstids.length == 1 ); 69 Assert.assertTrue( tstids[0] == 137 ); 70 71 //******************************************************************** 72 73 if(debug) System.out.println("Copy." ); 74 Cluster pclu2 = new McClusterTest((McClusterTest)pclu1); 75 76 { 77 int[] oids = pclu2.mcIdArray(); 78 Assert.assertTrue( oids.length == 3 ); 79 Assert.assertTrue( oids[0] == 1 ); 80 Assert.assertTrue( oids[1] == 22 ); 81 Assert.assertTrue( oids[2] == 333 ); 82 } 83 84 85 //******************************************************************** 86 87 if(debug) System.out.println( component+" ------------- All tests passed. -------------" ); 88 89 90 //******************************************************************** 91 } 92 93 }