|
| 1 | +/* |
| 2 | + * The MIT License |
| 3 | + * |
| 4 | + * Copyright 2015 tibo. |
| 5 | + * |
| 6 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + * of this software and associated documentation files (the "Software"), to deal |
| 8 | + * in the Software without restriction, including without limitation the rights |
| 9 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + * copies of the Software, and to permit persons to whom the Software is |
| 11 | + * furnished to do so, subject to the following conditions: |
| 12 | + * |
| 13 | + * The above copyright notice and this permission notice shall be included in |
| 14 | + * all copies or substantial portions of the Software. |
| 15 | + * |
| 16 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 22 | + * THE SOFTWARE. |
| 23 | + */ |
| 24 | + |
| 25 | +package info.debatty.java.utils; |
| 26 | + |
| 27 | +import org.junit.After; |
| 28 | +import org.junit.AfterClass; |
| 29 | +import org.junit.Before; |
| 30 | +import org.junit.BeforeClass; |
| 31 | +import org.junit.Test; |
| 32 | +import static org.junit.Assert.*; |
| 33 | + |
| 34 | +/** |
| 35 | + * |
| 36 | + * @author tibo |
| 37 | + */ |
| 38 | +public class SparseIntegerVectorTest { |
| 39 | + |
| 40 | + public SparseIntegerVectorTest() { |
| 41 | + } |
| 42 | + |
| 43 | + @BeforeClass |
| 44 | + public static void setUpClass() { |
| 45 | + } |
| 46 | + |
| 47 | + @AfterClass |
| 48 | + public static void tearDownClass() { |
| 49 | + } |
| 50 | + |
| 51 | + @Before |
| 52 | + public void setUp() { |
| 53 | + } |
| 54 | + |
| 55 | + @After |
| 56 | + public void tearDown() { |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Test of dotProduct method, of class SparseIntegerVector. |
| 61 | + */ |
| 62 | + @Test |
| 63 | + public void testDotProduct_SparseIntegerVector() { |
| 64 | + System.out.println("dotProduct"); |
| 65 | + SparseIntegerVector other = new SparseIntegerVector(new int[]{0, 2, 0, 1}); |
| 66 | + SparseIntegerVector instance = new SparseIntegerVector(new int[]{1, 2, 1, 0}); |
| 67 | + double expResult = 4.0; |
| 68 | + double result = instance.dotProduct(other); |
| 69 | + assertEquals(expResult, result, 0.0); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * Test of dotProduct method, of class SparseIntegerVector. |
| 74 | + */ |
| 75 | + @Test |
| 76 | + public void testDotProduct_doubleArr() { |
| 77 | + System.out.println("dotProduct"); |
| 78 | + double[] other = new double[]{0, 1.5, 2.0, 3.0}; |
| 79 | + SparseIntegerVector instance = new SparseIntegerVector(new int[]{1, 2, 0, 0}); |
| 80 | + double expResult = 3.0; |
| 81 | + double result = instance.dotProduct(other); |
| 82 | + assertEquals(expResult, result, 0.0); |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Test of norm method, of class SparseIntegerVector. |
| 87 | + */ |
| 88 | + @Test |
| 89 | + public void testNorm() { |
| 90 | + System.out.println("norm"); |
| 91 | + SparseIntegerVector instance = new SparseIntegerVector(new int[]{0, 0, 2}); |
| 92 | + double expResult = 2.0; |
| 93 | + double result = instance.norm(); |
| 94 | + assertEquals(expResult, result, 0.0); |
| 95 | + } |
| 96 | + |
| 97 | + /** |
| 98 | + * Test of jaccard method, of class SparseIntegerVector. |
| 99 | + */ |
| 100 | + @Test |
| 101 | + public void testJaccard() { |
| 102 | + System.out.println("jaccard"); |
| 103 | + SparseIntegerVector other = null; |
| 104 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 105 | + double expResult = 0.0; |
| 106 | + double result = instance.jaccard(other); |
| 107 | + assertEquals(expResult, result, 0.0); |
| 108 | + // TODO review the generated test code and remove the default call to fail. |
| 109 | + fail("The test case is a prototype."); |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * Test of union method, of class SparseIntegerVector. |
| 114 | + */ |
| 115 | + @Test |
| 116 | + public void testUnion() { |
| 117 | + System.out.println("union"); |
| 118 | + SparseIntegerVector other = null; |
| 119 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 120 | + int expResult = 0; |
| 121 | + int result = instance.union(other); |
| 122 | + assertEquals(expResult, result); |
| 123 | + // TODO review the generated test code and remove the default call to fail. |
| 124 | + fail("The test case is a prototype."); |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Test of intersection method, of class SparseIntegerVector. |
| 129 | + */ |
| 130 | + @Test |
| 131 | + public void testIntersection() { |
| 132 | + System.out.println("intersection"); |
| 133 | + SparseIntegerVector other = null; |
| 134 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 135 | + int expResult = 0; |
| 136 | + int result = instance.intersection(other); |
| 137 | + assertEquals(expResult, result); |
| 138 | + // TODO review the generated test code and remove the default call to fail. |
| 139 | + fail("The test case is a prototype."); |
| 140 | + } |
| 141 | + |
| 142 | + /** |
| 143 | + * Test of toString method, of class SparseIntegerVector. |
| 144 | + */ |
| 145 | + @Test |
| 146 | + public void testToString() { |
| 147 | + System.out.println("toString"); |
| 148 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 149 | + String expResult = ""; |
| 150 | + String result = instance.toString(); |
| 151 | + assertEquals(expResult, result); |
| 152 | + // TODO review the generated test code and remove the default call to fail. |
| 153 | + fail("The test case is a prototype."); |
| 154 | + } |
| 155 | + |
| 156 | + /** |
| 157 | + * Test of qgram method, of class SparseIntegerVector. |
| 158 | + */ |
| 159 | + @Test |
| 160 | + public void testQgram() { |
| 161 | + System.out.println("qgram"); |
| 162 | + SparseIntegerVector other = null; |
| 163 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 164 | + double expResult = 0.0; |
| 165 | + double result = instance.qgram(other); |
| 166 | + assertEquals(expResult, result, 0.0); |
| 167 | + // TODO review the generated test code and remove the default call to fail. |
| 168 | + fail("The test case is a prototype."); |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Test of size method, of class SparseIntegerVector. |
| 173 | + */ |
| 174 | + @Test |
| 175 | + public void testSize() { |
| 176 | + System.out.println("size"); |
| 177 | + SparseIntegerVector instance = new SparseIntegerVector(); |
| 178 | + int expResult = 0; |
| 179 | + int result = instance.size(); |
| 180 | + assertEquals(expResult, result); |
| 181 | + // TODO review the generated test code and remove the default call to fail. |
| 182 | + fail("The test case is a prototype."); |
| 183 | + } |
| 184 | + |
| 185 | +} |
0 commit comments