예제 #1
0
 /**
  * Create a circuit to evaluate (x1 or not(x1)) and then verify that its result is true for all
  * values of x1.
  */
 public void testAlwaysTrue() {
   if (Boolean.getBoolean("no.failures")) return;
   Circuit c = new Circuit();
   c.parse("x1 or NOT x1");
   assertTrue(c.evaluate(new boolean[] {Boolean.FALSE}));
   assertTrue(c.evaluate(new boolean[] {Boolean.TRUE}));
 }
예제 #2
0
 /**
  * Create a circuit to evaluate (x1 and x2) or x3 and then verify that its result is false for
  * input (false, true, false) and it is true for input (false, false, true).
  */
 public void testX1andX2orX3() {
   if (Boolean.getBoolean("no.failures")) return;
   Circuit c = new Circuit();
   c.parse("(x1 AND x2) or x3");
   assertFalse(c.evaluate(new boolean[] {Boolean.FALSE, Boolean.TRUE, Boolean.FALSE}));
   assertTrue(c.evaluate(new boolean[] {Boolean.FALSE, Boolean.FALSE, Boolean.TRUE}));
 }