aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCheng Chen2012-05-18 06:54:50 (EDT)
committerCheng Chen2012-05-18 06:54:50 (EDT)
commitca69ef2fa31b80239bb07ca4b8a188e5c7f169ec (patch)
tree7034fd54da999076f3ada3f07761b49c643d8f34
parentbbf4609037ec2b358989dab120b90f6ea867ca39 (diff)
downloadorg.eclipse.recommenders-ca69ef2fa31b80239bb07ca4b8a188e5c7f169ec.zip
org.eclipse.recommenders-ca69ef2fa31b80239bb07ca4b8a188e5c7f169ec.tar.gz
org.eclipse.recommenders-ca69ef2fa31b80239bb07ca4b8a188e5c7f169ec.tar.bz2
[snipmatch] add test case for ArgumentMatchNode classrefs/changes/25/6025/1
Change-Id: I96c988a6a918c1b78d0f8ad21da5309952e5a47e Signed-off-by: Cheng Chen <chengchendoc@gmail.com>
-rw-r--r--tests/org.eclipse.recommenders.tests.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/core/ArgumentMatchNodeTest.java134
1 files changed, 134 insertions, 0 deletions
diff --git a/tests/org.eclipse.recommenders.tests.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/core/ArgumentMatchNodeTest.java b/tests/org.eclipse.recommenders.tests.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/core/ArgumentMatchNodeTest.java
new file mode 100644
index 0000000..e82fa5e
--- /dev/null
+++ b/tests/org.eclipse.recommenders.tests.snipmatch.rcp/src/org/eclipse/recommenders/snipmatch/core/ArgumentMatchNodeTest.java
@@ -0,0 +1,134 @@
+/**
+ * Copyright (c) 2011, University of Science and Technology Beijing
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Cheng Chen - initial API and implementation.
+ */
+package org.eclipse.recommenders.snipmatch.core;
+
+import org.junit.*;
+import static org.junit.Assert.*;
+
+/**
+ * The class <code>ArgumentMatchNodeTest</code> contains tests for the class <code>{@link ArgumentMatchNode}</code>.
+ *
+ * @author Cheng Chen
+ */
+public class ArgumentMatchNodeTest {
+ /**
+ * Run the ArgumentMatchNode(String,EffectParameter) constructor test.
+ *
+ * @throws Exception
+ *
+ */
+ @Test
+ public void testArgumentMatchNode_1() throws Exception {
+ String arg = "obj";
+ EffectParameter param = new EffectParameter();
+ param.setMajorType("major");
+ param.setMinorType("minor");
+ param.setName("name");
+
+ ArgumentMatchNode result = new ArgumentMatchNode(arg, param);
+
+ assertNotNull(result);
+ assertEquals("obj", result.getArgument());
+ assertEquals(null, result.getMatchType());
+ assertEquals(null, result.getParent());
+ assertEquals(result.getParameter().getFullType(), "major:minor");
+ result.setMatchType(MatchType.EXACT_MATCH);
+ assertEquals(MatchType.EXACT_MATCH, result.getMatchType());
+ }
+
+ /**
+ * Run the MatchNode clone() method test.
+ *
+ * @throws Exception
+ *
+ */
+ @Test
+ public void testClone_1() throws Exception {
+ ArgumentMatchNode fixture = new ArgumentMatchNode("obj", new EffectParameter());
+ fixture.parent = new ArgumentMatchNode("expr", new EffectParameter());
+ fixture.matchType = MatchType.EXACT_MATCH;
+
+ MatchNode result = fixture.clone();
+
+ assertNotNull(result);
+ assertEquals(null, result.getParent());
+ assertEquals(result.getMatchType(), MatchType.EXACT_MATCH);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ */
+ @Test
+ public void testEquals_1() throws Exception {
+ ArgumentMatchNode fixture = new ArgumentMatchNode("match", new EffectParameter());
+ fixture.parent = new ArgumentMatchNode("parent", new EffectParameter());
+ fixture.matchType = MatchType.EXACT_MATCH;
+ Object other = new ArgumentMatchNode("arg", new EffectParameter());
+
+ boolean result = fixture.equals(other);
+
+ assertEquals(false, result);
+ }
+
+ /**
+ * Run the boolean equals(Object) method test.
+ *
+ * @throws Exception
+ *
+ */
+ @Test
+ public void testEquals_2() throws Exception {
+ ArgumentMatchNode fixture = new ArgumentMatchNode("arg", new EffectParameter());
+ fixture.parent = new ArgumentMatchNode("parent", new EffectParameter());
+ fixture.matchType = MatchType.EXACT_MATCH;
+ Object other = new ArgumentMatchNode("arg", new EffectParameter());
+
+ boolean result = fixture.equals(other);
+
+ assertEquals(true, result);
+ }
+
+ /**
+ * Perform pre-test initialization.
+ *
+ * @throws Exception
+ * if the initialization fails for some reason
+ *
+ */
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ /**
+ * Perform post-test clean-up.
+ *
+ * @throws Exception
+ * if the clean-up fails for some reason
+ *
+ */
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ /**
+ * Launch the test.
+ *
+ * @param args
+ * the command line arguments
+ *
+ */
+ public static void main(String[] args) {
+ new org.junit.runner.JUnitCore().run(ArgumentMatchNodeTest.class);
+ }
+} \ No newline at end of file