[Javamatch-cvs] javamatch/src/net/sourceforge/javamatch/query/test BooleanEqualsTest.java,NONE,1.1 R
Status: Pre-Alpha
Brought to you by:
iterson
From: Walter v. I. <it...@us...> - 2004-09-13 08:45:58
|
Update of /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv711/net/sourceforge/javamatch/query/test Modified Files: ContainsTest.java DataObject.java GreaterThanTest.java LessThanTest.java MaximumTest.java MinimumTest.java NumberEqualsTest.java RangeTest.java StringEqualsTest.java TestAll.java Added Files: BooleanEqualsTest.java RegexMatchesTest.java Log Message: Added regex, booleanEquals, test for null members --- NEW FILE: RegexMatchesTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import java.util.regex.*; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class RegexMatchesTest tests the RegexMatches query */ public class RegexMatchesTest extends TestCase { public RegexMatchesTest(String name) { super(name); } public void testMatch() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "a*b"); DataObject dataObject = new DataObject("aaab"); assertEquals(1.0, regexMatches.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testMismatch() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "a*b"); DataObject dataObject = new DataObject("aaabc"); assertEquals(0.0, regexMatches.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testNullRegex() { try { RegexMatches regexMatches = new RegexMatches("stringValue", null); fail("Shouldn't be able to craete RegexMatches with null expression"); } catch (NullPointerException npe) { // should occur } } public void testInvalidPattern() { try { RegexMatches regexMatches = new RegexMatches("stringValue", "\\"); fail("Shouldn't be able to craete RegexMatches with invalid pattern"); } catch (PatternSyntaxException pse) { // should occur } } public void testNullMember() { try { RegexMatches regexMatches = new RegexMatches(null, ""); fail("Shouldn't be able to create RegexMatches with null member"); } catch (NullPointerException npe) { // should occur } } } Index: DataObject.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/DataObject.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** DataObject.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- DataObject.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 21,24 **** --- 21,25 ---- private int intValue; private String stringValue; + private boolean boolValue; public DataObject(int intValue) { *************** *** 30,33 **** --- 31,38 ---- } + public DataObject(boolean boolValue) { + this.boolValue = boolValue; + } + public DataObject(int intValue, String stringValue) { this.intValue = intValue; *************** *** 42,44 **** --- 47,53 ---- return stringValue; } + + public boolean getBoolValue() { + return boolValue; + } } Index: StringEqualsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/StringEqualsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** StringEqualsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- StringEqualsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + StringEquals stringEquals = new StringEquals(null, ""); + fail("Shouldn't be able to create StringEquals with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: LessThanTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/LessThanTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** LessThanTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- LessThanTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 59,61 **** --- 59,70 ---- } } + + public void testNullMember() { + try { + LessThan lessThan = new LessThan(null, 0); + fail("Shouldn't be able to create LessThan with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: NumberEqualsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/NumberEqualsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** NumberEqualsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- NumberEqualsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 49,51 **** --- 49,60 ---- } } + + public void testNullMember() { + try { + NumberEquals numberEquals = new NumberEquals(null, 0.0); + fail("Shouldn't be able to create NumberEquals with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } --- NEW FILE: BooleanEqualsTest.java --- /* JavaMatch: Matching engine for Java runtime data structures * Copyright (C) 2004 Walter van Iterson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.javamatch.query.test; import junit.framework.*; import net.sourceforge.javamatch.engine.*; import net.sourceforge.javamatch.query.*; /** * Class BooleanEqualsTest tests the BooleanEquals query */ public class BooleanEqualsTest extends TestCase { public BooleanEqualsTest(String name) { super(name); } public void testTrue() { try { BooleanEquals booleanEquals = new BooleanEquals("boolValue"); DataObject dataObject = new DataObject(true); assertEquals(1.0, booleanEquals.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testFalse() { try { BooleanEquals booleanEquals = new BooleanEquals("boolValue"); DataObject dataObject = new DataObject(false); assertEquals(0.0, booleanEquals.getMatchValue(dataObject), 0.001f); } catch (MatchException me) { fail("unable to match"); } } public void testNullMember() { try { StringEquals stringEquals = new StringEquals(null, ""); fail("Shouldn't be able to create StringEquals with null member"); } catch (NullPointerException npe) { // should occur } } } Index: TestAll.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/TestAll.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** TestAll.java 9 Sep 2004 14:18:59 -0000 1.2 --- TestAll.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 46,49 **** --- 46,51 ---- suite.addTestSuite(ContainsTest.class); suite.addTestSuite(NotQueryTest.class); + suite.addTestSuite(RegexMatchesTest.class); + suite.addTestSuite(BooleanEqualsTest.class); // ... and others return suite; Index: MinimumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MinimumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MinimumTest.java 6 Sep 2004 09:14:37 -0000 1.2 --- MinimumTest.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 142,144 **** --- 142,153 ---- } } + + public void testNullMember() { + try { + Minimum minimum = new Minimum(null); + fail("Shouldn't be able to create Minimum with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: MaximumTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/MaximumTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MaximumTest.java 6 Sep 2004 09:14:30 -0000 1.2 --- MaximumTest.java 13 Sep 2004 08:45:48 -0000 1.3 *************** *** 142,144 **** --- 142,153 ---- } } + + public void testNullMember() { + try { + Maximum maximum = new Maximum(null); + fail("Shouldn't be able to create Maximum with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: RangeTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/RangeTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** RangeTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- RangeTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + Range range = new Range(null, 0, 0); + fail("Shouldn't be able to create Range with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: ContainsTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/ContainsTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ContainsTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- ContainsTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 79,81 **** --- 79,90 ---- } } + + public void testNullMember() { + try { + Contains contains = new Contains(null, ""); + fail("Shouldn't be able to create Contains with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } Index: GreaterThanTest.java =================================================================== RCS file: /cvsroot/javamatch/javamatch/src/net/sourceforge/javamatch/query/test/GreaterThanTest.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** GreaterThanTest.java 3 Sep 2004 08:21:23 -0000 1.1.1.1 --- GreaterThanTest.java 13 Sep 2004 08:45:48 -0000 1.2 *************** *** 59,61 **** --- 59,70 ---- } } + + public void testNullMember() { + try { + GreaterThan greaterThan = new GreaterThan(null, 0); + fail("Shouldn't be able to create GreaterThan with null member"); + } catch (NullPointerException npe) { + // should occur + } + } } |