[Javabdd-checkins] JavaBDD_tests/bdd BasicTests.java,1.1,1.2
Brought to you by:
joewhaley
From: John W. <joe...@us...> - 2004-11-17 08:21:41
|
Update of /cvsroot/javabdd/JavaBDD_tests/bdd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9734/bdd Modified Files: BasicTests.java Log Message: More test cases. Index: BasicTests.java =================================================================== RCS file: /cvsroot/javabdd/JavaBDD_tests/bdd/BasicTests.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BasicTests.java 19 Oct 2004 06:52:08 -0000 1.1 --- BasicTests.java 17 Nov 2004 08:21:32 -0000 1.2 *************** *** 181,184 **** --- 181,232 ---- } + static boolean isFreed(BDD b) { + return b.hashCode() == -1; + } + + void testApplyWith(BDDFactory bdd, BDDFactory.BDDOp op, + boolean b1, boolean b2, boolean b3, boolean b4) { + BDD a, b, c, d; + a = bdd.zero(); b = bdd.zero(); + c = a; d = b; + Assert.assertTrue(!isFreed(d)); + a.applyWith(b, op); + Assert.assertEquals(b1, a.isOne()); + Assert.assertEquals(b1, c.isOne()); + Assert.assertTrue(isFreed(b)); + Assert.assertTrue(isFreed(d)); + a.free(); + + a = bdd.zero(); b = bdd.one(); + c = a; d = b; + Assert.assertTrue(!isFreed(d)); + a.applyWith(b, op); + Assert.assertEquals(b2, a.isOne()); + Assert.assertEquals(b2, c.isOne()); + Assert.assertTrue(isFreed(b)); + Assert.assertTrue(isFreed(d)); + a.free(); + + a = bdd.one(); b = bdd.zero(); + c = a; d = b; + Assert.assertTrue(!isFreed(d)); + a.applyWith(b, op); + Assert.assertEquals(b3, a.isOne()); + Assert.assertEquals(b3, c.isOne()); + Assert.assertTrue(isFreed(b)); + Assert.assertTrue(isFreed(d)); + a.free(); + + a = bdd.one(); b = bdd.one(); + c = a; d = b; + Assert.assertTrue(!isFreed(d)); + a.applyWith(b, op); + Assert.assertEquals(b4, a.isOne()); + Assert.assertEquals(b4, c.isOne()); + Assert.assertTrue(isFreed(b)); + Assert.assertTrue(isFreed(d)); + a.free(); + } + public void testOr() { reset(); *************** *** 295,298 **** --- 343,365 ---- } + public void testApplyWith() { + reset(); + Assert.assertTrue(hasNext()); + while (hasNext()) { + BDDFactory bdd = nextFactory(); + // TODO: more tests + testApplyWith(bdd, BDDFactory.and, false, false, false, true); + testApplyWith(bdd, BDDFactory.or, false, true, true, true); + testApplyWith(bdd, BDDFactory.xor, false, true, true, false); + testApplyWith(bdd, BDDFactory.imp, true, true, false, true); + testApplyWith(bdd, BDDFactory.biimp, true, false, false, true); + testApplyWith(bdd, BDDFactory.diff, false, false, true, false); + testApplyWith(bdd, BDDFactory.less, false, true, false, false); + testApplyWith(bdd, BDDFactory.invimp, true, false, true, true); + testApplyWith(bdd, BDDFactory.nand, true, true, true, false); + testApplyWith(bdd, BDDFactory.nor, true, false, false, false); + } + } + public void testIte() { reset(); |