Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java')
-rw-r--r--dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java65
1 files changed, 65 insertions, 0 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java
new file mode 100644
index 00000000000..bed9559b320
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMICommandConstructCommand.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Ericsson and others.
+ * 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:
+ * Ericsson - Initial Implementation
+ *******************************************************************************/
+package org.eclipse.cdt.dsf.mi.service.command.commands;
+
+import static org.junit.Assert.assertEquals;
+
+import org.eclipse.cdt.dsf.datamodel.IDMContext;
+import org.eclipse.cdt.dsf.mi.service.command.commands.MICommand;
+import org.eclipse.cdt.dsf.mi.service.command.output.MIInfo;
+import org.junit.Test;
+
+/**
+ * Test verifying that the construct command method handles separators and
+ * escaping correctly
+ *
+ * @author qtobsod
+ *
+ */
+public class TestMICommandConstructCommand {
+
+ @Test
+ public void multipleParametersShouldHaveCorrectSeparators() {
+ // Setup
+ MICommand<MIInfo> target = new MICommand<MIInfo>(new TestContext(),
+ "-test-operation");
+ target.setOptions(new String[] { "-a a_test\\with slashes",
+ "-b \"hello\"", "-c c_test" });
+ target.setParameters(new String[] { "-param1 param", "param2",
+ "-param3" });
+
+ // Act
+ String result = target.constructCommand();
+
+ // Assert
+ assertEquals(
+ "Wrong syntax for command",
+ "-test-operation \"-a a_test\\\\with slashes\" \"-b \\\"hello\\\"\" \"-c c_test\" -- \"-param1 param\" param2 -param3\n",
+ result);
+ }
+
+ private class TestContext implements IDMContext {
+
+ public IDMContext[] getParents() {
+ return null;
+ }
+
+ public String getSessionId() {
+ return null;
+ }
+
+ public Object getAdapter(Class adapter) {
+ return null;
+ }
+
+ }
+
+}

Back to the top