edu.rice.cs.drjava.model.definitions.reducedmodel
Class BackSlashTest

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.drjava.model.definitions.reducedmodel.BraceReductionTestCase
                  extended by edu.rice.cs.drjava.model.definitions.reducedmodel.BackSlashTest
All Implemented Interfaces:
ReducedModelStates, Test

public final class BackSlashTest
extends BraceReductionTestCase
implements ReducedModelStates

Test the interactions between double quotes and backslashes.

Version:
$Id: BackSlashTest.java 4653 2008-08-26 14:46:35Z rcartwright $

Field Summary
protected  ReducedModelControl model0
           
protected  ReducedModelControl model1
           
protected  ReducedModelControl model2
           
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Fields inherited from interface edu.rice.cs.drjava.model.definitions.reducedmodel.ReducedModelStates
FREE, INSIDE_BLOCK_COMMENT, INSIDE_DOUBLE_QUOTE, INSIDE_LINE_COMMENT, INSIDE_SINGLE_QUOTE, STUTTER
 
Constructor Summary
BackSlashTest()
           
 
Method Summary
protected  void insertGap(BraceReduction model, int size)
          Convenience function to insert a number of non-special characters into a reduced model.
protected  void setUp()
          Initializes the reduced models used in the tests.
static Test suite()
          Creates a test suite for JUnit to use.
 void testBackSlashBeforeDoubleEscape()
          Tests the case when a backslash is inserted before two backslashes.
 void testChainEffect()
          Tests cases where a long chain of backslashes and quotes can be all altered with a simple insertion or deletion of a special character.
 void testDeleteAndCombine()
          Tests the case where deletion combines a backslash and a quote or two backslashes.
 void testDeleteAndCombine2()
          Tests more of the same sort of cases as found in testDeleteAndCombine().
 void testDeleteAndCombine3()
          More of the same sort of cases as found in testDeleteAndCombine().
 void testInsertBetweenDoubleEscape()
          Tests the case where a backslash breaks up two backslashes together.
 void testInsideQuoteNext()
          Tests the relationship between backslashes and quotes.
 void testInsideQuotePrevious()
          Tests the relationship between backslash characters and quote characters.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText, 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
 

Field Detail

model0

protected ReducedModelControl model0

model1

protected ReducedModelControl model1

model2

protected ReducedModelControl model2
Constructor Detail

BackSlashTest

public BackSlashTest()
Method Detail

setUp

protected void setUp()
              throws Exception
Initializes the reduced models used in the tests.

Overrides:
setUp in class BraceReductionTestCase
Throws:
Exception - This convention is mandated by JUnit.TestCase, the superclass of this class.

suite

public static Test suite()
Creates a test suite for JUnit to use.

Returns:
a test suite for JUnit

insertGap

protected void insertGap(BraceReduction model,
                         int size)
Convenience function to insert a number of non-special characters into a reduced model.

Overrides:
insertGap in class BraceReductionTestCase
Parameters:
model - the model being modified
size - the number of characters being inserted

testInsideQuotePrevious

public void testInsideQuotePrevious()
Tests the relationship between backslash characters and quote characters. It focuses on the case where the backslash is inserted first before the quote.


testInsideQuoteNext

public void testInsideQuoteNext()
Tests the relationship between backslashes and quotes. Focuses on the case where a backslash is inserted and turns a regular quote into an escaped quote.


testBackSlashBeforeDoubleEscape

public void testBackSlashBeforeDoubleEscape()
Tests the case when a backslash is inserted before two backslashes. The existing double escape is broken and the first two backslashes become a double escape with the third backslash ending up alone.


testInsertBetweenDoubleEscape

public void testInsertBetweenDoubleEscape()
Tests the case where a backslash breaks up two backslashes together. The newly inserted backslash and the first backslash form a new double escape and the second backslash in the previous double escape becomes free.


testDeleteAndCombine

public void testDeleteAndCombine()
Tests the case where deletion combines a backslash and a quote or two backslashes. The deletion of characters in between the two special characters brings them together and unites them into a 2-character special token.


testDeleteAndCombine2

public void testDeleteAndCombine2()
Tests more of the same sort of cases as found in testDeleteAndCombine().


testDeleteAndCombine3

public void testDeleteAndCombine3()
More of the same sort of cases as found in testDeleteAndCombine().


testChainEffect

public void testChainEffect()
Tests cases where a long chain of backslashes and quotes can be all altered with a simple insertion or deletion of a special character.