Skip to content

Commit

Permalink
Fix bugs in Test.
Browse files Browse the repository at this point in the history
  • Loading branch information
fcyu committed Jul 4, 2018
1 parent 62947bb commit 555c635
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void dot() throws Exception {
SparseVector other = new SparseVector();
other.put(1, 1.5);
other.put(2, 3);
assertEquals(1.5, vector.dot(other), 0);
assertEquals(1.5, vector.dot(other), 1e-4);
}

@Test
Expand Down
22 changes: 11 additions & 11 deletions src/test/java/proteomics/Types/SparseVectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ public void setUp() throws Exception {
public void add() throws Exception {
vector.add(1, 2.1);
vector.add(2, 3);
assertEquals(2.6, vector.get(1), 0);
assertEquals(3, vector.get(2), 0);
assertEquals(2.6, vector.get(1), 1e-4);
assertEquals(3, vector.get(2), 1e-4);
}

@Test
public void put() throws Exception {
vector.put(1, 2.1);
vector.put(2, 3);
assertEquals(2.1, vector.get(1), 0);
assertEquals(3, vector.get(2), 0);
assertEquals(2.1, vector.get(1), 1e-4);
assertEquals(3, vector.get(2), 1e-4);
}

@Test
public void get() throws Exception {
assertEquals(0.5, vector.get(1), 0);
assertEquals(1.2, vector.get(3), 0);
assertEquals(3.2, vector.get(11), 0);
assertEquals(0.5, vector.get(1), 1e-4);
assertEquals(1.2, vector.get(3), 1e-4);
assertEquals(3.2, vector.get(11), 1e-4);
}

@Test
Expand All @@ -59,17 +59,17 @@ public void idxSet() throws Exception {

@Test
public void getMaxValue() throws Exception {
assertEquals(3.2, vector.getMaxValue(), 0);
assertEquals(3.2, vector.getMaxValue(), 1e-4);
}

@Test
public void getMinValue() throws Exception {
assertEquals(0.5, vector.getMinValue(), 0);
assertEquals(0.5, vector.getMinValue(), 1e-4);
}

@Test
public void norm2square() throws Exception {
assertEquals(11.93, vector.norm2square(), 0);
assertEquals(11.93, vector.norm2square(), 1e-4);
}

@Test
Expand All @@ -79,7 +79,7 @@ public void dot() throws Exception {
other.put(2, 5);
other.put(11, 2);
other.put(30, 4);
assertEquals(7.9, vector.dot(other), 1e-6);
assertEquals(7.9, vector.dot(other), 1e-4);
}

@Test
Expand Down

0 comments on commit 555c635

Please sign in to comment.