Skip to content
Snippets Groups Projects
Commit 12d98e9c authored by Goik Martin's avatar Goik Martin
Browse files

Two Bugfixes

parent 8819cfa4
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,10 @@ public class D_SumTest extends ExaminationTestDefaults { ...@@ -15,7 +15,10 @@ public class D_SumTest extends ExaminationTestDefaults {
if (expected != actual) { if (expected != actual) {
final String errorMessage = "Expected " + expected + " == mitigatedSum(" + i + " , " + j + ") rather than »" final String errorMessage = "Expected " + expected + " == mitigatedSum(" + i + " , " + j + ") rather than »"
+ actual + "«. Wanna set a breakpoint for debugging?"; + actual + "«. Wanna set a breakpoint for debugging?";
Assert.assertEquals(errorMessage, D_Sum.mitigatedSum((byte)i, (byte) j)); // Yet again for debugging
// Call again to allow for debugging
final byte actual2 = D_Sum.mitigatedSum(i, j);
Assert.fail(errorMessage);
} }
} }
...@@ -23,7 +26,7 @@ public class D_SumTest extends ExaminationTestDefaults { ...@@ -23,7 +26,7 @@ public class D_SumTest extends ExaminationTestDefaults {
@Test @Test
public void test() { public void test() {
for (byte i = Byte.MIN_VALUE; i < ++i; ) { // ... i < BYTE.MAX_VALUE; i++ loops endlessly due to byte overflow for (byte i = Byte.MIN_VALUE; i < ++i; ) { // ... i < BYTE.MAX_VALUE; i++ loops endlessly due to byte overflow
for (byte j = Byte.MIN_VALUE; j < j++; ) { for (byte j = Byte.MIN_VALUE; j < ++j; ) {
final int sum = i + j; final int sum = i + j;
if (sum < Byte.MIN_VALUE) { if (sum < Byte.MIN_VALUE) {
assertByteSum(Byte.MIN_VALUE, i, j); assertByteSum(Byte.MIN_VALUE, i, j);
......
...@@ -15,15 +15,18 @@ public class D_SumTest extends ExaminationTestDefaults { ...@@ -15,15 +15,18 @@ public class D_SumTest extends ExaminationTestDefaults {
if (expected != actual) { if (expected != actual) {
final String errorMessage = "Expected " + expected + " == mitigatedSum(" + i + " , " + j + ") rather than »" final String errorMessage = "Expected " + expected + " == mitigatedSum(" + i + " , " + j + ") rather than »"
+ actual + "«. Wanna set a breakpoint for debugging?"; + actual + "«. Wanna set a breakpoint for debugging?";
Assert.assertEquals(errorMessage, D_Sum.mitigatedSum((byte)i, (byte) j)); // Yet again for debugging
// Call again to allow for debugging
final byte actual2 = D_Sum.mitigatedSum(i, j);
Assert.fail(errorMessage);
} }
} }
@Marking(points = 6) @Marking(points = 6)
@Test @Test
public void test() { public void test() {
for (byte i = Byte.MIN_VALUE; i < ++i; ) { for (byte i = Byte.MIN_VALUE; i < ++i; ) { // ... i < BYTE.MAX_VALUE; i++ loops endlessly due to byte overflow
for (byte j = Byte.MIN_VALUE; j < j++; ) { for (byte j = Byte.MIN_VALUE; j < ++j; ) {
final int sum = i + j; final int sum = i + j;
if (sum < Byte.MIN_VALUE) { if (sum < Byte.MIN_VALUE) {
assertByteSum(Byte.MIN_VALUE, i, j); assertByteSum(Byte.MIN_VALUE, i, j);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment