samples/apifest1/boolcircuit/test/org/netbeans/apifest/boolcircuit/CircuitTest.java
1 package org.netbeans.apifest.boolcircuit;
3 import junit.framework.TestCase;
4 import junit.framework.*;
6 // BEGIN: apifest.CircuitTest
7 /** The initial quest for this APIFest is to create an API for boolean
8 * circuits. Such API shall be able to compose a boolean circuit from
9 * basic elements and evaluate the result given initial values for
12 * The basic elements include:
14 * <li>negation - has one input and one output and changes 0 on input to
15 * on output 1 and 1 to 0
16 * <li>and - has two inputs and one output. The output is 1 only if both
17 * inputs are 1, otherwise it is 0
18 * <li>or - has two inputs and one output. The output is 1 always,
19 * except in the case when both inputs are 0
23 * The boolean circuit can be used to represent boolean formulas and
24 * compute the results for certain values of its inputs. The individual
25 * tasks described as tests bellow.
31 * <a href="http://en.wikipedia.org/wiki/Truth_table">
34 * <a href="http://en.wikipedia.org/wiki/Tautology_(logic)">
38 public class CircuitTest extends TestCase {
40 // your code shall run without any permissions
43 public CircuitTest(String testName) {
47 protected void setUp() throws Exception {
50 protected void tearDown() throws Exception {
55 * Create a circuit to evaluate x1 and x2 and then
56 * verify that its result is false for input (false, true) and
57 * it is true for input (true, true).
59 public void testX1andX2() {
64 * Create a circuit to evaluate (x1 and x2) or x3 and then
65 * verify that its result is false for input (false, true, false) and
66 * it is true for input (false, false, true).
68 public void testX1andX2orX3() {
72 * Create a circuit to evaluate (x1 or not(x1)) and then
73 * verify that its result is true for all values of x1.
75 public void testAlwaysTrue() {
80 // END: apifest.CircuitTest