diff options
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/cxx/externaltool/ArgsSeparatorTest.java')
-rw-r--r-- | codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/cxx/externaltool/ArgsSeparatorTest.java | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/cxx/externaltool/ArgsSeparatorTest.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/cxx/externaltool/ArgsSeparatorTest.java new file mode 100644 index 00000000000..0623c6477a3 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/cxx/externaltool/ArgsSeparatorTest.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2012 Google, Inc 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: + * Alex Ruiz (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.core.cxx.externaltool; + +import static org.junit.Assert.assertArrayEquals; +import junit.framework.TestCase; + +/** + * Tests for <code>{@link ArgsSeparator}</code>. + */ +@SuppressWarnings("nls") +public class ArgsSeparatorTest extends TestCase { + private ArgsSeparator separator; + + @Override + protected void setUp() { + separator = new ArgsSeparator(); + } + + public void testWithSpaceAsDelimiter() { + String[] args = separator.splitArguments("abc def ghi"); + assertArrayEquals(new String[] { "abc", "def", "ghi" }, args); + } + + public void testWithSingleQuote() { + String[] args = separator.splitArguments("abc 'def ghi' jkl"); + assertArrayEquals(new String[] { "abc", "def ghi", "jkl" }, args); + } + + public void testWithDoubleQuote() { + String[] args = separator.splitArguments("abc \"def ghi\" jkl"); + assertArrayEquals(new String[] { "abc", "def ghi", "jkl" }, args); + } + + public void testWithEscapedSingleQuote() { + String[] args = separator.splitArguments("abc 'def \\' ghi' jkl"); + assertArrayEquals(new String[] { "abc", "def \\' ghi", "jkl" }, args); + } + + public void testWithEscapedDoubleQuote() { + String[] args = separator.splitArguments("abc 'def \\\" ghi' jkl"); + assertArrayEquals(new String[] { "abc", "def \\\" ghi", "jkl" }, args); + } +} |