jtulach@53: package org.netbeans.apifest.boolcircuit; jtulach@53: jtulach@53: import junit.framework.TestCase; jtulach@53: import junit.framework.*; jtulach@53: jtulach@53: // BEGIN: apitest.day2.RealTest jtulach@53: /** This file contains the APIFest quest for day 2. Simply, turn the jtulach@132: * boolean circuit into circuit that can compute with double jtulach@132: * values from 0 to 1. jtulach@53: *

jtulach@53: * This means that where ever a boolean was used to represent input or jtulach@53: * output values, one can now use any double number from >= 0 and <= 1. jtulach@53: * Still, to support backward compatibility, the operations with booleans jtulach@53: * has to be kept available and have to work. In fact False shall be jtulach@53: * treated as 0 and True as 1. jtulach@53: *

jtulach@132: * The basic elements has to be modified to work on doubles jtulach@132: * in the following way: jtulach@53: *

jtulach@53: *

jtulach@132: * However as the circuits with doubles are more rich than plain boolean jtulach@132: * circuits, there is additional requirement to allow any user of your API jtulach@132: * to write its own "element" type. This is all going to be exercise in jtulach@132: * the tests bellow which you are supposed to implement. jtulach@53: */ jtulach@53: public class RealTest extends TestCase { jtulach@53: static { jtulach@53: // your code shall run without any permissions jtulach@53: } jtulach@53: jtulach@53: public RealTest(String testName) { jtulach@53: super(testName); jtulach@53: } jtulach@53: jtulach@53: jtulach@53: /** First of all create a circuit which will evaluate jtulach@53: * expression (X1 and X2) or not(x1). Hold the circuit jtulach@53: * in some variable. jtulach@53: * jtulach@53: * Feed this circuit with x1=true, x2=false, assert result is false jtulach@53: * jtulach@53: * Feed the same circuit with x1=false, x2=true, assert result is true jtulach@53: * jtulach@53: * Feed the same circuit with x1=0.0, x2=1.0, assert result is 1.0 jtulach@53: * jtulach@53: * Feed the same circuit with x1=0.5, x2=0.5, assert result is 0.625 jtulach@53: * jtulach@132: * Feed the same circuit with x1=0.0, x2=2.0, make sure it jtulach@132: * throws an exception jtulach@53: */ jtulach@53: public void testX1andX2orNotX1() { jtulach@53: fail("testX1andX2orNotX1"); jtulach@53: } jtulach@53: jtulach@53: /** Ensure that one variable cannot be filled with two different values. jtulach@53: * Create a circuit for x1 and x1. Make sure that for any usage of your jtulach@53: * API that would not lead to x1 * x1 result, an exception is thrown. jtulach@53: * For example if there was a way to feed the circuit with two different jtulach@53: * values 0.3 and 0.5 an exception is thrown indicating that this is jtulach@53: * improper use of the circuit. jtulach@53: */ jtulach@53: public void testImproperUseOfTheCircuit() { jtulach@53: fail("testImproperUseOfTheCircuit"); jtulach@53: } jtulach@53: jtulach@132: /** Write your own element type called "gte" that will have two jtulach@132: * inputs and one output. jtulach@53: * The output value will be 1 if x1 >= x2 and 0 otherwise. jtulach@53: * jtulach@53: * Create jtulach@53: * circuit for following expression: (x1 and not(x1)) gte x1 jtulach@53: * jtulach@53: * Feed the circuit with 0.5 and verify the result is 0 jtulach@53: * jtulach@53: * Feed the same circuit with 1 and verify the result is 0 jtulach@53: * jtulach@53: * Feed the same circuit with 0 and verify the result is 1 jtulach@53: */ jtulach@53: public void testGreaterThanEqualElement() { jtulach@53: fail("testGreaterThanEqualElement"); jtulach@53: } jtulach@53: } jtulach@53: // END: apitest.day2.RealTest jtulach@53: