1 package baseCode.io.reader;
2
3 import java.io.IOException;
4 import java.io.InputStream;
5
6 import junit.framework.TestCase;
7 import baseCode.dataStructure.matrix.SparseDoubleMatrix2DNamed;
8 import baseCode.io.reader.SparseDoubleMatrixReader;
9 import baseCode.util.RegressionTesting;
10
11 /***
12 *
13 *
14 * <hr>
15 * <p>Copyright (c) 2004 Columbia University
16 * @author pavlidis
17 * @version $Id: TestSparseDoubleMatrixReader.java,v 1.1 2005/03/17 13:58:42 pavlidis Exp $
18 */
19 public class TestSparseDoubleMatrixReader extends TestCase {
20 SparseDoubleMatrix2DNamed matrix = null;
21 InputStream is = null;
22 InputStream isa = null;
23 SparseDoubleMatrixReader reader = null;
24
25
26
27 protected void setUp() throws Exception {
28 super.setUp();
29 reader = new SparseDoubleMatrixReader();
30 is = TestSparseDoubleMatrixReader.class
31 .getResourceAsStream( "/data/JW-testmatrix.txt" );
32 isa = TestSparseDoubleMatrixReader.class
33 .getResourceAsStream( "/data/adjacencylist-testmatrix.txt" );
34 }
35
36
37
38
39 public void testReadStream() {
40 try {
41 matrix = ( SparseDoubleMatrix2DNamed ) reader.read ( isa, null );
42 String actualReturn = matrix.toString();
43 String expectedReturn = RegressionTesting.readTestResult(TestSparseDoubleMatrixReader.class
44 .getResourceAsStream("/data/JW-testoutputSym.txt"));
45
46 assertEquals( "return value", expectedReturn, actualReturn );
47
48 } catch ( IOException e ) {
49 e.printStackTrace();
50 }
51
52 }
53
54 public void testReadJW() {
55 try {
56 matrix = ( SparseDoubleMatrix2DNamed ) reader.readJW( is );
57 String actualReturn = matrix.toString();
58 String expectedReturn = RegressionTesting.readTestResult(TestSparseDoubleMatrixReader.class
59 .getResourceAsStream("/data/JW-testoutput.txt"));
60
61 assertEquals( "return value", expectedReturn, actualReturn );
62
63 } catch ( IOException e ) {
64 e.printStackTrace();
65 } catch ( IllegalAccessException e ) {
66
67 e.printStackTrace();
68 } catch ( NoSuchFieldException e ) {
69
70 e.printStackTrace();
71 }
72 }
73
74 }