From 3cf9fc1ba5a1fff9e8e043065516897de8f3c519 Mon Sep 17 00:00:00 2001 From: Lukas Reichwein Date: Tue, 16 Jul 2019 19:29:59 +0200 Subject: [PATCH] changed tests for the conjugation of conplex numbers to use hamcrest asserrThat --- .../conjugationOfComplexNumbersTest.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/test/java/com/ugsbo/complexnumcalc/conjugationOfComplexNumbersTest.java b/src/test/java/com/ugsbo/complexnumcalc/conjugationOfComplexNumbersTest.java index e996959..457ad39 100644 --- a/src/test/java/com/ugsbo/complexnumcalc/conjugationOfComplexNumbersTest.java +++ b/src/test/java/com/ugsbo/complexnumcalc/conjugationOfComplexNumbersTest.java @@ -1,6 +1,7 @@ package com.ugsbo.complexnumcalc; -import static org.junit.Assert.assertTrue; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.*; import org.junit.Test; @@ -15,8 +16,18 @@ public class conjugationOfComplexNumbersTest { ComplexNumber actual = complexNumber.conjugationOf(); - assertTrue("TheConjugatedComplexNumberOfAComplexNumberWithOnlyARealPartIsTheRealPart", expected.equals(actual)); - //TODO change equals to equalTo - //assertThat("TheConjugatedComplexNumberOfAComplexNumberWithOnlyARealPartIsTheRealPart", expected, equalsTo(actual)); + assertThat("The conjugated complex Number of a complex number with only a real part is the real part", expected, equalTo(actual)); + } + + @Test + public void TheConjugatedComplexNumberOfAComplexNumberShouldBeTheComplexNumberWithSwapedSignImaginaryPart_ButItIsNot() { + Double realPart = Double.valueOf(4); + Double imaginaryPart = Double.valueOf(5); + ComplexNumber complexNumber = new ComplexNumber(realPart, imaginaryPart); + ComplexNumber expected = new ComplexNumber(realPart, -imaginaryPart); + + ComplexNumber actual = complexNumber.conjugationOf(); + + assertThat("The conjugated complex number of a complex number is the complex number with swaped sign in the imaginary part", expected, equalTo(actual)); } } \ No newline at end of file