From dc5ea1e78eee529090d739774889639fab1c181c Mon Sep 17 00:00:00 2001 From: Stefan Suhren Date: Wed, 14 Jan 2015 14:12:03 +0100 Subject: Assignment No.13 after correction --- .../in/inf/java1/aufgabe13/UnaryOperatorTests.java | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java (limited to 'tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java') diff --git a/tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java b/tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java new file mode 100644 index 0000000..997f71e --- /dev/null +++ b/tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java @@ -0,0 +1,60 @@ +/** + * + */ +package de.fhswf.in.inf.java1.aufgabe13; + +import static org.junit.Assert.assertEquals; + +import java.util.Stack; + +import org.junit.Test; + +import de.fhswf.in.inf.java1.aufgabe12.UnaryOperator; +import de.fhswf.in.inf.java1.aufgabe12.UnaryTemplate; + +/** + * Tests the BinaryOperators. + * + * @author $Author: $ + * @version $Revision: $, $Date: $ UTC + */ +public class UnaryOperatorTests +{ + + /** + * Test for the UnaryTemplate class initialized with sin. + */ + @Test + public final void testOperatorSin() + { + // Sin is tested + UnaryOperator tester = new UnaryTemplate("sin"); + + // Test + Stack test = new Stack<>(); + + test.add(0.0); + tester.eval(test); + + assertEquals(0.0, (double) test.pop(), 0); + } + + /** + * Test for the UnaryTemplate class initialized with cos. + */ + @Test + public final void testOperatorCos() + { + // Cos is tested + UnaryOperator tester = new UnaryTemplate("cos"); + + // Test + Stack test = new Stack<>(); + + test.add(0.0); + tester.eval(test); + + assertEquals(1.0, (double) test.pop(), 0); + } + +} -- cgit v1.2.3-70-g09d2