summaryrefslogtreecommitdiffstats
path: root/tests/de/fhswf/in/inf/java1/aufgabe13/UnaryOperatorTests.java
blob: 997f71e00b9328852ad0613ecefad14c8b9b9c6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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<Double> 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<Double> test = new Stack<>();

      test.add(0.0);
      tester.eval(test);

      assertEquals(1.0, (double) test.pop(), 0);
   }

}