Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
32   108   10   3.2
0   58   0.31   5
10     1  
2    
 
  OperatorTest       Line # 25 31 9 95% 0.95
  OperatorTest.MyOperator       Line # 101 1 1 100% 1.0
 
  (25)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
14    */
15   
16    package org.qedeq.kernel.bo.logic.model;
17   
18    import org.qedeq.kernel.bo.test.QedeqBoTestCase;
19   
20    /**
21    * Test class.
22    *
23    * @author Michael Meyling
24    */
 
25    public class OperatorTest extends QedeqBoTestCase {
26   
27    private Operator operator;
28   
29    /**
30    * Constructor.
31    *
32    */
 
33  0 toggle public OperatorTest() {
34  0 super();
35    }
36   
37    /**
38    * Constructor.
39    *
40    * @param name Test case name.
41    *
42    */
 
43  25 toggle public OperatorTest(final String name) {
44  25 super(name);
45    }
46   
 
47  25 toggle protected void setUp() throws Exception {
48  25 super.setUp();
49  25 operator = getOperator("op", 2);
50    }
51   
 
52  5 toggle public void testGetArgumentNumber() throws Exception {
53  5 assertEquals(2, operator.getArgumentNumber());
54    }
55   
 
56  5 toggle public void testGetName() throws Exception {
57  5 assertEquals("op", operator.getName());
58    }
59   
 
60  5 toggle public void testEquals() throws Exception {
61  5 Operator op0 = getOperator("op", 2);
62  5 assertEquals(op0, operator);
63  5 assertEquals(operator, op0);
64  5 Operator op1 = getOperator("op1", 2);
65  5 assertFalse(operator.equals("op"));
66  5 assertFalse(op1.equals(operator));
67  5 assertFalse(operator.equals(op1));
68  5 Operator op2 = getOperator("op", 3);
69  5 assertFalse(op2.equals(operator));
70  5 assertFalse(operator.equals(op2));
71  5 Operator op3 = new Operator("op", 2) {};
72  5 assertFalse(op3.equals(operator));
73  5 assertFalse(operator.equals(op3));
74    }
75   
 
76  5 toggle public void testToString() throws Exception {
77  5 assertEquals("op(*, *)", operator.toString());
78  5 Operator op0 = getOperator("oper", 0);
79  5 assertEquals("oper", op0.toString());
80    }
81   
 
82  5 toggle public void testHashCode() throws Exception {
83  5 Operator op0 = getOperator("op", 2);
84  5 assertEquals(operator.hashCode(), op0.hashCode());
85  5 Operator op1 = new Operator("op", 2) {};
86  5 assertFalse(operator.hashCode() == op1.hashCode());
87  5 Operator op2 = getOperator("op2", 2);
88  5 assertFalse(operator.hashCode() == op2.hashCode());
89  5 Operator op3 = getOperator("op", 3);
90  5 assertFalse(operator.hashCode() == op3.hashCode());
91    }
92   
 
93  12 toggle protected Operator getOperator(final String name, final int number) {
94  12 return new MyOperator(name, number);
95    }
96   
97    /**
98    * Testing an operator class.
99    * @author m31
100    */
 
101    class MyOperator extends Operator {
102   
 
103  12 toggle public MyOperator(final String name, final int number) {
104  12 super(name, number);
105    }
106    }
107   
108    }