edu.rice.cs.drjava.model.definitions.indent
Class QuestionExistsCharInStmtTest

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.indent.IndentRulesTestCase
                  extended by edu.rice.cs.drjava.model.definitions.indent.QuestionExistsCharInStmtTest
All Implemented Interfaces:
Test

public final class QuestionExistsCharInStmtTest
extends IndentRulesTestCase

Tests the question rule which determines if the given findChar is found between the start of the statement and the endChar, which must exist on the current line.

This is done in the context of determining if a colon that was found on the current line is part of a ternary operator. Hence, we use endChar=':' and findChar='?'.

Version:
$Id: QuestionExistsCharInStmtTest.java 4519 2008-06-15 07:14:29Z rcartwright $

Field Summary
 
Fields inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRulesTestCase
_doc, TEST_INDENT_LEVEL
 
Fields inherited from class edu.rice.cs.drjava.DrJavaTestCase
TEST_DRJAVA_CONFIG_PROPERTY
 
Constructor Summary
QuestionExistsCharInStmtTest()
           
 
Method Summary
 void testColonInTernaryOpIgnoreWhitespaceAndComments()
          Ensures that a colon that is part of a ternary operator is detected.
 void testColonInTernaryOpMultiLineStmts()
          Ensures that a colon that is part of a ternary operator is detected.
 void testColonInTernaryOpOneLineStmts()
          Ensures that a colon that is part of a ternary operator is detected.
 void testColonInTernaryOpTwoStmtsOnOneLine()
          Ensures that a colon that is part of a ternary operator is detected.
 void testColonNotInTernaryOpDueToQuestionMarkInCommentsOrQuotes()
          Ensures that a colon that is part of a ternary operator is detected.
 void testColonNotInTernaryOpMultiLineStmts()
          Ensures that a colon that is part of a ternary operator is detected.
 
Methods inherited from class edu.rice.cs.drjava.model.definitions.indent.IndentRulesTestCase
_assertContents, _setDocText, setUp, tearDown
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText
 
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

QuestionExistsCharInStmtTest

public QuestionExistsCharInStmtTest()
Method Detail

testColonInTernaryOpOneLineStmts

public void testColonInTernaryOpOneLineStmts()
                                      throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that this rule works for one line statements.

Throws:
BadLocationException

testColonInTernaryOpTwoStmtsOnOneLine

public void testColonInTernaryOpTwoStmtsOnOneLine()
                                           throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that this rule works when there are two statements on the same line. Essentially, that it uses the first colon that it finds on the line as the endChar.

Throws:
BadLocationException

testColonInTernaryOpMultiLineStmts

public void testColonInTernaryOpMultiLineStmts()
                                        throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that a colon in a multi-line ternary op statement is detected.

Throws:
BadLocationException

testColonInTernaryOpIgnoreWhitespaceAndComments

public void testColonInTernaryOpIgnoreWhitespaceAndComments()
                                                     throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that whitespace, single-line comments and multi-line comments in between the ':' character and the '?' character are ignored.

Throws:
BadLocationException

testColonNotInTernaryOpDueToQuestionMarkInCommentsOrQuotes

public void testColonNotInTernaryOpDueToQuestionMarkInCommentsOrQuotes()
                                                                throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that a '?' in quotes or single-line comments or multi-line comments is not detected - and hence that a colon is not party of a ternary op.

Throws:
BadLocationException

testColonNotInTernaryOpMultiLineStmts

public void testColonNotInTernaryOpMultiLineStmts()
                                           throws BadLocationException
Ensures that a colon that is part of a ternary operator is detected. Tests that a colon that is part of a multi-line statement is not falsely identified as belonging to a ternary op.

Throws:
BadLocationException