diff options
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf')
4 files changed, 196 insertions, 0 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/ClassAccessor.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/ClassAccessor.java new file mode 100644 index 00000000000..e70c2436967 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/ClassAccessor.java @@ -0,0 +1,38 @@ +package org.eclipse.cdt.dsf.mi.service; + +import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext; +import org.eclipse.cdt.dsf.mi.service.ExpressionService.MIExpressionDMC; + +public class ClassAccessor { + + public static class MIExpressionDMCAccessor { + private MIExpressionDMC miExprDmc; + + public MIExpressionDMCAccessor(IExpressionDMContext dmc) { + miExprDmc = (MIExpressionDMC) dmc; + } + + @Override + public boolean equals(Object other) { + return miExprDmc.equals(other); + } + + @Override + public int hashCode() { + return miExprDmc.hashCode(); + } + + @Override + public String toString() { + return miExprDmc.toString(); + } + + public String getExpression() { + return miExprDmc.getExpression(); + } + + public String getRelativeExpression() { + return miExprDmc.getRelativeExpression(); + } + } +} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/AllTests.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/AllTests.java new file mode 100644 index 00000000000..3bd0d7378a9 --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/AllTests.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 org.junit.runner.RunWith; +import org.junit.runners.Suite; + +/* + * This class is meant to be empty. It enables us to define + * the annotations which list all the different JUnit class we + * want to run. When creating a new test class, it should be + * added to the list below. + */ + +@RunWith(Suite.class) +@Suite.SuiteClasses({ + TestMIBreakInsertCommand.class, + TestMICommandConstructCommand.class + /* Add your test class here */ + }) + +public class AllTests {} diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java new file mode 100644 index 00000000000..d83d2c8f84b --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/TestMIBreakInsertCommand.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.debug.service.IBreakpoints.IBreakpointsTargetDMContext; +import org.eclipse.cdt.dsf.mi.service.command.commands.MIBreakInsert; +import org.junit.Test; + +/** + * Verifies that the break insert MI command have the correct path substitution. + * + * @author qtobsod + * + */ +public class TestMIBreakInsertCommand { + + @Test + public void pathShouldNotContainDoubleBackSlashes() { + MIBreakInsert target = new MIBreakInsert(new TestContext(), false, + false, null, 1, "c:\\test\\this\\path:14", 4); + + assertEquals("Wrong syntax for command", + "-break-insert -i 1 -p 4 c:\\test\\this\\path:14\n", target + .constructCommand()); + } + + @Test + public void pathWithSlashesShouldNotBeSubstituted() { + MIBreakInsert target = new MIBreakInsert(new TestContext(), false, + false, null, 1, "/test/this/path:14", 4); + + assertEquals("Wrong syntax for command", + "-break-insert -i 1 -p 4 /test/this/path:14\n", target + .constructCommand()); + } + + private class TestContext implements IBreakpointsTargetDMContext { + + public IDMContext[] getParents() { + return null; + } + + public String getSessionId() { + return null; + } + + public Object getAdapter(Class adapter) { + return null; + } + } + +} 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; + } + + } + +} |