1 45 46 package edu.rice.cs.drjava.model.definitions.indent; 47 48 import javax.swing.text.BadLocationException ; 49 50 58 public class ActionStartPrevLinePlusMultilinePreserveTest extends IndentRulesTestCase { 59 60 65 private IndentRuleAction makeAction(String [] suffices, 66 int cursorLine, int cursorPos, 67 int psrvLine, int psrvPos) { 68 return new ActionStartPrevLinePlusMultilinePreserve(suffices, 69 cursorLine, cursorPos, 70 psrvLine, psrvPos); 71 } 72 73 82 public void helperCommentTest(String start, int loc, int endLoc, String finish) throws 83 BadLocationException { 84 _setDocText(start); 85 _doc.setCurrentLocation(loc); 86 makeAction(new String []{" * \n", " */"},0,3,0,3).indentLine(_doc, Indenter.ENTER_KEY_PRESS); 87 assertEquals(endLoc, _doc.getCurrentLocation()); 88 assertEquals(finish, _doc.getText()); 90 } 91 92 public void test1() throws BadLocationException { 93 helperCommentTest("/**\n", 94 4, 7, 95 "/**\n * \n */"); 96 } 97 98 public void test2() throws BadLocationException { 99 helperCommentTest(" /**\n", 100 7, 13, 101 " /**\n * \n */"); 102 } 103 104 public void test3() throws BadLocationException { 105 helperCommentTest("/* abc\ndefg\n hijklmnop", 106 7, 10, 107 "/* abc\n * defg\n */\n hijklmnop"); 108 } 109 110 public void test4() throws BadLocationException { 111 helperCommentTest("/* \nThis is a comment */", 112 4, 7, 113 "/* \n * This is a comment */\n */"); 114 } 115 116 public void test5() throws BadLocationException { 117 helperCommentTest("/* This is code\n and more */", 118 16, 19, 119 "/* This is code\n * and more */\n */"); 120 } 121 122 public void test6() throws BadLocationException { 123 helperCommentTest("/* This \nis a comment block\n That is already closed */", 137 9, 12, 138 "/* This \n * is a comment block\n */\n That is already closed */"); 139 } 140 141 public void test7() throws BadLocationException { 142 helperCommentTest("/* This \nis a comment block\n * That is already closed \n */", 159 9, 12, 160 "/* This \n * is a comment block\n */\n * That is already closed \n */"); 161 } 162 163 public void xtest8() throws BadLocationException { 164 helperCommentTest("/* ABC \n */", 171 8, 11, 172 "/* ABC \n * */\n */"); 173 } 174 175 public void xtest9() throws BadLocationException { 176 helperCommentTest("/**\n * Text\n */", 185 4, 7, 186 "/**\n * \n * Text\n */"); 187 } 188 189 public void test10() throws BadLocationException { 190 197 helperCommentTest("/** This is \nbad */ **/", 198 13, 16, 199 "/** This is \n * bad */ **/\n */"); 200 } 201 202 public void xtest11() throws BadLocationException { 203 209 helperCommentTest("/** ABC **/ \n /** ABC **/", 210 13, 13, 211 "/** ABC **/ \n/** ABC **/"); 212 } 213 214 } | Popular Tags |