author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:58:11 +0200 | |
changeset 154 | 0fd5e9c500b9 |
parent 153 | b5cbb797ec0a |
child 263 | 7e8e995065c5 |
permissions | -rw-r--r-- |
jtulach@52 | 1 |
package org.netbeans.apifest.boolcircuit; |
jtulach@52 | 2 |
|
jtulach@52 | 3 |
import junit.framework.TestCase; |
jtulach@52 | 4 |
import junit.framework.*; |
jtulach@52 | 5 |
|
jtulach@52 | 6 |
// BEGIN: apifest.CircuitTest |
jtulach@52 | 7 |
/** The initial quest for this APIFest is to create an API for boolean |
jtulach@52 | 8 |
* circuits. Such API shall be able to compose a boolean circuit from |
jtulach@52 | 9 |
* basic elements and evaluate the result given initial values for |
jtulach@52 | 10 |
* input variables. |
jtulach@52 | 11 |
* <p> |
jtulach@52 | 12 |
* The basic elements include: |
jtulach@52 | 13 |
* <ul> |
jtulach@52 | 14 |
* <li>negation - has one input and one output and changes 0 on input to |
jtulach@52 | 15 |
* on output 1 and 1 to 0 |
jtulach@52 | 16 |
* <li>and - has two inputs and one output. The output is 1 only if both |
jtulach@52 | 17 |
* inputs are 1, otherwise it is 0 |
jtulach@154 | 18 |
* <li>or - has two inputs and one output. The output is 1 always, |
jtulach@154 | 19 |
* except in the case when both inputs are 0 |
jtulach@52 | 20 |
* </ul> |
jtulach@52 | 21 |
* |
jtulach@52 | 22 |
* <p> |
jtulach@154 | 23 |
* The boolean circuit can be used to represent boolean formulas and |
jtulach@154 | 24 |
* compute the results for certain values of its inputs. The individual |
jtulach@154 | 25 |
* tasks described as tests bellow. |
jtulach@52 | 26 |
* |
jtulach@52 | 27 |
* <p> |
jtulach@52 | 28 |
* Links of interest: |
jtulach@52 | 29 |
* <ul> |
jtulach@154 | 30 |
* <li> |
jtulach@154 | 31 |
* <a href="http://en.wikipedia.org/wiki/Truth_table"> |
jtulach@154 | 32 |
* Truth table</a> |
jtulach@154 | 33 |
* <li> |
jtulach@154 | 34 |
* <a href="http://en.wikipedia.org/wiki/Tautology_(logic)"> |
jtulach@154 | 35 |
* Taugology</a> |
jtulach@52 | 36 |
* </ul> |
jtulach@52 | 37 |
*/ |
jtulach@52 | 38 |
public class CircuitTest extends TestCase { |
jtulach@52 | 39 |
static { |
jtulach@52 | 40 |
// your code shall run without any permissions |
jtulach@52 | 41 |
} |
jtulach@52 | 42 |
|
jtulach@52 | 43 |
public CircuitTest(String testName) { |
jtulach@52 | 44 |
super(testName); |
jtulach@52 | 45 |
} |
jtulach@52 | 46 |
|
jtulach@52 | 47 |
protected void setUp() throws Exception { |
jtulach@52 | 48 |
} |
jtulach@52 | 49 |
|
jtulach@52 | 50 |
protected void tearDown() throws Exception { |
jtulach@52 | 51 |
} |
jtulach@52 | 52 |
|
jtulach@52 | 53 |
|
jtulach@52 | 54 |
/** |
jtulach@52 | 55 |
* Create a circuit to evaluate x1 and x2 and then |
jtulach@52 | 56 |
* verify that its result is false for input (false, true) and |
jtulach@52 | 57 |
* it is true for input (true, true). |
jtulach@52 | 58 |
*/ |
jtulach@52 | 59 |
public void testX1andX2() { |
jtulach@52 | 60 |
fail("task1"); |
jtulach@52 | 61 |
} |
jtulach@52 | 62 |
|
jtulach@52 | 63 |
/** |
jtulach@52 | 64 |
* Create a circuit to evaluate (x1 and x2) or x3 and then |
jtulach@52 | 65 |
* verify that its result is false for input (false, true, false) and |
jtulach@52 | 66 |
* it is true for input (false, false, true). |
jtulach@52 | 67 |
*/ |
jtulach@52 | 68 |
public void testX1andX2orX3() { |
jtulach@52 | 69 |
fail("task2"); |
jtulach@52 | 70 |
} |
jtulach@52 | 71 |
/** |
jtulach@52 | 72 |
* Create a circuit to evaluate (x1 or not(x1)) and then |
jtulach@52 | 73 |
* verify that its result is true for all values of x1. |
jtulach@52 | 74 |
*/ |
jtulach@52 | 75 |
public void testAlwaysTrue() { |
jtulach@52 | 76 |
fail("task3"); |
jtulach@52 | 77 |
} |
jtulach@52 | 78 |
|
jtulach@52 | 79 |
} |
jtulach@52 | 80 |
// END: apifest.CircuitTest |