100% Code Coverage beim bisherigen Code
This commit is contained in:
parent
f7417b8a3b
commit
fe22278fe6
|
@ -17,7 +17,7 @@ public class GrosseZahl {
|
||||||
zahl[w] = Integer.parseInt(String.valueOf(d.charAt(w)));
|
zahl[w] = Integer.parseInt(String.valueOf(d.charAt(w)));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Incorrect Input!");
|
throw new IllegalArgumentException("falscher Input");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,11 +118,11 @@ public class GrosseZahl {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int length() {
|
public int length() {
|
||||||
return zahl.length;
|
return zahl.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int numberAt(int i) {
|
public int numberAt(int i) {
|
||||||
return zahl[i];
|
return zahl[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,6 @@ public class Node<T> {
|
||||||
|
|
||||||
private Logger logger = Logger.getLogger(getClass().getName());
|
private Logger logger = Logger.getLogger(getClass().getName());
|
||||||
|
|
||||||
public Node() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Node(T value) {
|
public Node(T value) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
@ -35,11 +32,6 @@ public class Node<T> {
|
||||||
return right;
|
return right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return super.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof Node) {
|
if (obj instanceof Node) {
|
||||||
|
|
|
@ -12,9 +12,4 @@ public class Tree<T> {
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj) {
|
|
||||||
if(obj instanceof Tree) return root.equals(obj);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -49,6 +49,7 @@ public class CharCollectionTest {
|
||||||
@Test
|
@Test
|
||||||
public void equals() {
|
public void equals() {
|
||||||
assertEquals(new CharCollection("llo"), new CharCollection("lol"));
|
assertEquals(new CharCollection("llo"), new CharCollection("lol"));
|
||||||
|
assertNotEquals(new CharCollection("Hallo"), "Hallo");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -14,6 +14,18 @@ public class GrosseZahlTest {
|
||||||
assertNotEquals(new GrosseZahl(14), 14);
|
assertNotEquals(new GrosseZahl(14), 14);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void length() {
|
||||||
|
assertEquals(4, new GrosseZahl("1234").length());
|
||||||
|
assertNotEquals(5, new GrosseZahl(1234).length());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void numberAt() {
|
||||||
|
assertEquals(5, new GrosseZahl("125").numberAt(2));
|
||||||
|
assertNotEquals(5, new GrosseZahl(125).numberAt(1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void add() {
|
public void add() {
|
||||||
|
@ -33,6 +45,7 @@ public class GrosseZahlTest {
|
||||||
assertNotEquals(new GrosseZahl(43), new GrosseZahl(100).sub(new GrosseZahl(58)));
|
assertNotEquals(new GrosseZahl(43), new GrosseZahl(100).sub(new GrosseZahl(58)));
|
||||||
assertEquals(new GrosseZahl(100), new GrosseZahl(150).sub(new GrosseZahl(50)));
|
assertEquals(new GrosseZahl(100), new GrosseZahl(150).sub(new GrosseZahl(50)));
|
||||||
assertEquals(new GrosseZahl(0), new GrosseZahl(10).sub(new GrosseZahl("10")));
|
assertEquals(new GrosseZahl(0), new GrosseZahl(10).sub(new GrosseZahl("10")));
|
||||||
|
assertEquals(new GrosseZahl(0), new GrosseZahl(10).sub(new GrosseZahl(15)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -64,4 +77,9 @@ public class GrosseZahlTest {
|
||||||
assertNotEquals(new GrosseZahl(2), new GrosseZahl("7").ggT(new GrosseZahl(13)));
|
assertNotEquals(new GrosseZahl(2), new GrosseZahl("7").ggT(new GrosseZahl(13)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
public void wrongInput() {
|
||||||
|
new GrosseZahl("42B");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,8 @@ import java.util.Set;
|
||||||
import java.util.TreeSet;
|
import java.util.TreeSet;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotEquals;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
|
||||||
public class VorlesungsTest {
|
public class VorlesungsTest {
|
||||||
|
@ -29,5 +31,8 @@ public class VorlesungsTest {
|
||||||
assertEquals(Integer.valueOf(16), tree.getRoot().getRight().getValue());
|
assertEquals(Integer.valueOf(16), tree.getRoot().getRight().getValue());
|
||||||
|
|
||||||
assertEquals(tree.getRoot(), node);
|
assertEquals(tree.getRoot(), node);
|
||||||
|
|
||||||
|
|
||||||
|
assertNotEquals(node, "HalloWelt");
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue