Coverage Report - net.sourceforge.combean.test.mathprog.linalg.TestSparseVectorWithConstantPattern
 
Classes in this File Line Coverage Branch Coverage Complexity
TestSparseVectorWithConstantPattern
93%
27/29
N/A
1
 
 1  
 /*
 2  
     This file is part of Combean.
 3  
 
 4  
     Combean is free software; you can redistribute it and/or modify
 5  
     it under the terms of the GNU General Public License as published by
 6  
     the Free Software Foundation; either version 2 of the License, or
 7  
     (at your option) any later version.
 8  
 
 9  
     Combean is distributed in the hope that it will be useful,
 10  
     but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12  
     GNU General Public License for more details.
 13  
 
 14  
     You should have received a copy of the GNU General Public License
 15  
     along with Combean; if not, write to the Free Software
 16  
     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17  
 */
 18  
 /*
 19  
  * Created on 04.08.2006
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.test.mathprog.linalg;
 23  
 
 24  
 import junit.framework.TestCase;
 25  
 import net.sourceforge.combean.interfaces.mathprog.linalg.SparseVector;
 26  
 import net.sourceforge.combean.mathprog.linalg.SparseVectorWithConstantPattern;
 27  
 import net.sourceforge.combean.mathprog.linalg.statics.SparseVectorConverter;
 28  
 import net.sourceforge.combean.test.helpers.checks.Check;
 29  
 
 30  
 public class TestSparseVectorWithConstantPattern extends TestCase {
 31  
 
 32  
     public static void main(String[] args) {
 33  0
         junit.textui.TestRunner.run(TestSparseVectorWithConstantPattern.class);
 34  0
     }
 35  
 
 36  
     /**
 37  
      * @param arg0
 38  
      */
 39  
     public TestSparseVectorWithConstantPattern(String arg0) {
 40  9
         super(arg0);
 41  9
     }
 42  
 
 43  
     /* (non-Javadoc)
 44  
      * @see junit.framework.TestCase#setUp()
 45  
      */
 46  
     protected void setUp() throws Exception {
 47  9
         super.setUp();
 48  9
     }
 49  
 
 50  
     /* (non-Javadoc)
 51  
      * @see junit.framework.TestCase#tearDown()
 52  
      */
 53  
     protected void tearDown() throws Exception {
 54  9
         super.tearDown();
 55  9
     }
 56  
     
 57  
     public final void testVectorWithConstantValue() {
 58  3
         SparseVector vec =
 59  
             new SparseVectorWithConstantPattern(5, 2.0);
 60  
         
 61  3
         assertEquals(5, vec.getDimension());
 62  3
         assertEquals(5, vec.getNumIterations());
 63  
         
 64  3
         double[] v = SparseVectorConverter.convertToDoubleArray(vec);
 65  3
         final double[] expected = {2.0, 2.0, 2.0, 2.0, 2.0};
 66  3
         Check.compareDoubleArrays(expected, v, 0.0);
 67  3
     }
 68  
 
 69  
     public final void testVectorWithConstantNonZeroBlock() {
 70  3
         SparseVector vec =
 71  
             new SparseVectorWithConstantPattern(5, 2.0, 2, 3);
 72  
         
 73  3
         assertEquals(5, vec.getDimension());
 74  3
         assertEquals(2, vec.getNumIterations());
 75  
         
 76  3
         double[] v = SparseVectorConverter.convertToDoubleArray(vec);
 77  3
         final double[] expected = {0.0, 0.0, 2.0, 2.0, 0.0};
 78  3
         Check.compareDoubleArrays(expected, v, 0.0);
 79  3
     }
 80  
 
 81  
     public final void testVectorWithConstantNonZeroProgression() {
 82  3
         SparseVector vec =
 83  
             new SparseVectorWithConstantPattern(5, 2.0, 1, 3, 2);
 84  
         
 85  3
         assertEquals(5, vec.getDimension());
 86  3
         assertEquals(2, vec.getNumIterations());
 87  
 
 88  3
         double[] v = SparseVectorConverter.convertToDoubleArray(vec);
 89  3
         final double[] expected = {0.0, 2.0, 0.0, 2.0, 0.0};
 90  3
         Check.compareDoubleArrays(expected, v, 0.0);
 91  3
     }
 92  
 }