Lukas Reichwein
5 years ago
2 changed files with 93 additions and 10 deletions
-
28src/main/java/com/ugsbo/complexnumcalc/ComplexNumber.java
-
69src/test/java/com/ugsbo/complexnumcalc/EqualsComplexNumversTest.java
@ -0,0 +1,69 @@ |
|||||
|
package com.ugsbo.complexnumcalc; |
||||
|
|
||||
|
import static org.junit.Assert.assertFalse; |
||||
|
import static org.junit.Assert.assertTrue; |
||||
|
|
||||
|
import org.junit.Test; |
||||
|
|
||||
|
public class EqualsComplexNumversTest { |
||||
|
|
||||
|
@Test |
||||
|
public void TwoEqualNumbersWithOnlyRealPart_AreNotDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertTrue("TwoEqualNumbersShouldBeEqual", actual); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void TwoNotEqualNumbersWithOnlyRealPart_AreDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(0)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(6), Double.valueOf(0)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertFalse("TwoNotEqualNumbersShouldNotBeEqual", actual); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void TwoEqualNumbersWithOnlyImaginaryPart_AreNotDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertTrue("TwoEqualComplexNumbersShouldBeEqual", actual); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void TwoNotEqualNumbersWithOnlyImaginaryPart_AreDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(5)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(0), Double.valueOf(6)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertFalse("TwoNotEqualComplexNumbersShouldNotBeEqual", actual); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void TwoEqualComplexNumbers_AreNotDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertTrue("TwoEqualComplexNumbersShouldBeEqual", actual); |
||||
|
} |
||||
|
|
||||
|
@Test |
||||
|
public void TwoNotEqualComplexNumbers_AreDetectedAsEqual() { |
||||
|
ComplexNumber firstNumber = new ComplexNumber(Double.valueOf(5), Double.valueOf(5)); |
||||
|
ComplexNumber secoundNumber = new ComplexNumber(Double.valueOf(6), Double.valueOf(6)); |
||||
|
|
||||
|
boolean actual = firstNumber.equals(secoundNumber); |
||||
|
|
||||
|
assertFalse("TwoNotEqualComplexNumbersShouldNotBeEqual", actual); |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue