1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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);
}
}
|