edu.rice.cs.util
Class ArgumentTokenizerTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.rice.cs.drjava.DrJavaTestCase
              extended by edu.rice.cs.util.ArgumentTokenizerTest
All Implemented Interfaces:
Test

public class ArgumentTokenizerTest
extends DrJavaTestCase

Tests that an ArgumentTokenizer can correctly divide up a string into command line-style arguments. Tries to follow the precedent set by a Unix bash shell in most cases.

Version:
$Id: ArgumentTokenizerTest.java 4691 2008-12-02 23:33:27Z dlsmith $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
ArgumentTokenizerTest(String name)
          Creates a new ArgumentTokenizer to be used in every test.
 
Method Summary
protected  void _assertTokenized(String typed, String[] expected)
          Asserts that the given string is tokenized to become the given array of string arguments.
protected  void _assertTokenized(String typed, String[] expected, boolean stringify)
          Asserts that the given string is tokenized to become the given array of string arguments.
 void testTokenizeAndStringify()
          Tests that arguments can be "stringified" properly.
 void testTokenizeArguments()
          Tests that the argument tokenizer can split up a simple list of arguments.
 void testTokenizeEscapedArgs()
          Tests that escaped characters just return the character itself.
 void testTokenizeQuotedEscapedArgs()
          Tests that within a quote, everything is correctly escaped.
 void testTokenizeSingleQuotedArgs()
          Tests that single quotes can be used as argument delimiters.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText, setUp, tearDown
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ArgumentTokenizerTest

public ArgumentTokenizerTest(String name)
Creates a new ArgumentTokenizer to be used in every test.

Method Detail

_assertTokenized

protected void _assertTokenized(String typed,
                                String[] expected)
Asserts that the given string is tokenized to become the given array of string arguments.

Parameters:
typed - A string containing all arguments (as typed by a user)
expected - What the tokenizer should return

_assertTokenized

protected void _assertTokenized(String typed,
                                String[] expected,
                                boolean stringify)
Asserts that the given string is tokenized to become the given array of string arguments.

Parameters:
typed - A string containing all arguments (as typed by a user)
expected - What the tokenizer should return
stringify - Whether to format the resulting arguments to print out as Strings.

testTokenizeArguments

public void testTokenizeArguments()
Tests that the argument tokenizer can split up a simple list of arguments.


testTokenizeEscapedArgs

public void testTokenizeEscapedArgs()
Tests that escaped characters just return the character itself. Escaped whitespace is considered a character, not a delimiter. (This is how Unix behaves.) not currently enforcing any behavior for a simple implementation using a StreamTokenizer


testTokenizeQuotedEscapedArgs

public void testTokenizeQuotedEscapedArgs()
Tests that within a quote, everything is correctly escaped. (Special characters are passed to the program correctly.)


testTokenizeSingleQuotedArgs

public void testTokenizeSingleQuotedArgs()
Tests that single quotes can be used as argument delimiters. This is consistent with Unix, not with DOS.


testTokenizeAndStringify

public void testTokenizeAndStringify()
Tests that arguments can be "stringified" properly. (ie. formatted to be printed as a String)