Source Code Cross Referenced for CCIndentUnitTestCase.java in  » IDE-Netbeans » cnd » org » netbeans » modules » cnd » editor » cplusplus » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » cnd » org.netbeans.modules.cnd.editor.cplusplus 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * Portions Copyrighted 2007 Sun Microsystems, Inc.
027:         */
028:
029:        package org.netbeans.modules.cnd.editor.cplusplus;
030:
031:        import org.netbeans.modules.cnd.editor.api.CodeStyle;
032:        import org.netbeans.modules.cnd.editor.options.EditorOptions;
033:
034:        /**
035:         * Class was taken from java
036:         * Links point to java IZ.
037:         * C/C++ specific tests begin from testReformatSimpleClass
038:         *
039:         * @author Alexander Simon
040:         */
041:        public class CCIndentUnitTestCase extends CCFormatterBaseUnitTestCase {
042:
043:            public CCIndentUnitTestCase(String testMethodName) {
044:                super (testMethodName);
045:            }
046:
047:            // indent new line tests
048:
049:            public void testJavadocEnterNothingAfterCaret() {
050:                setLoadDocumentText("/**\n" + " * text|\n" + " */\n");
051:                indentNewLine();
052:                assertDocumentTextAndCaret("Incorrect new-line indent", "/**\n"
053:                        + " * text\n" + " *|\n" + " */\n");
054:
055:            }
056:
057:            public void testJavadocEnterTextAfterCaret() {
058:                setLoadDocumentText("/**\n" + " * break|text\n" + " */\n");
059:                indentNewLine();
060:                assertDocumentTextAndCaret("Incorrect new-line indent", "/**\n"
061:                        + " * break\n" + " * |text\n" + " */\n");
062:
063:            }
064:
065:            public void testJavadocEnterStarAfterCaret() {
066:                setLoadDocumentText("/**\n" + " * text|*/\n");
067:                indentNewLine();
068:                assertDocumentTextAndCaret("Incorrect new-line indent", "/**\n"
069:                        + " * text\n" + " |*/\n");
070:
071:            }
072:
073:            public void testEnterInMultiLineSystemOutPrintln() {
074:                setLoadDocumentText("void m() {\n" + "    printf(|\n" + "\n");
075:                indentNewLine();
076:                assertDocumentTextAndCaret("Incorrect new-line indent",
077:                        "void m() {\n" + "    printf(\n" + "            |\n"
078:                                + "\n");
079:
080:            }
081:
082:            public void testEnterInMultiLineSystemOutPrintlnLineThree() {
083:                setLoadDocumentText("void m() {\n" + "    printf(\n"
084:                        + "            \"haf\"|\n" + "\n");
085:                indentNewLine();
086:                assertDocumentTextAndCaret("Incorrect new-line indent",
087:                        "void m() {\n" + "    printf(\n"
088:                                + "            \"haf\"\n" + "            |\n"
089:                                + "\n");
090:
091:            }
092:
093:            public void testEnterInMultiLineSystemOutPrintlnAfterSemiColon() {
094:                setLoadDocumentText("void m() {\n" + "    printf(\n"
095:                        + "            \"haf\");|\n" + "\n");
096:                indentNewLine();
097:                assertDocumentTextAndCaret("Incorrect new-line indent",
098:                        "void m() {\n" + "    printf(\n"
099:                                + "            \"haf\");\n" + "    |\n" + "\n");
100:
101:            }
102:
103:            //    public void testEnterInMultiLineClassDeclaration() {
104:            //        setLoadDocumentText(
105:            //                "public class C\n"
106:            //                + "        : Runnable\n {|\n"
107:            //                + "}\n"
108:            //                );
109:            //        indentNewLine();
110:            //        assertDocumentTextAndCaret("Incorrect new-line indent",
111:            //                "public class C\n"
112:            //                + "        : Runnable {\n"
113:            //                + "    |\n"
114:            //                + "}\n"
115:            //                );
116:            //        
117:            //    }
118:
119:            public void testEnterAfterIf() {
120:                setLoadDocumentText("if (true)|\n");
121:                indentNewLine();
122:                assertDocumentTextAndCaret("Incorrect new-line indent",
123:                        "if (true)\n" + "    |\n");
124:            }
125:
126:            public void testEnterAfterFor() {
127:                setLoadDocumentText("for (int i = 0; i < 10; i++)|\n");
128:                indentNewLine();
129:                assertDocumentTextAndCaret("Incorrect new-line indent",
130:                        "for (int i = 0; i < 10; i++)\n" + "    |\n");
131:            }
132:
133:            public void testEnterAfterWhile() {
134:                setLoadDocumentText("while (true)|\n");
135:                indentNewLine();
136:                assertDocumentTextAndCaret("Incorrect new-line indent",
137:                        "while (true)\n" + "    |\n");
138:            }
139:
140:            public void testEnterAfterDo() {
141:                setLoadDocumentText("do|\n");
142:                indentNewLine();
143:                assertDocumentTextAndCaret("Incorrect new-line indent", "do\n"
144:                        + "    |\n");
145:            }
146:
147:            public void testEnterAfterIfStmt() {
148:                setLoadDocumentText("if (true)\n" + "    stmt;|\n");
149:                indentNewLine();
150:                assertDocumentTextAndCaret("Incorrect new-line indent",
151:                        "if (true)\n" + "    stmt;\n" + "|\n");
152:            }
153:
154:            public void testEnterAfterIfElse() {
155:                setLoadDocumentText("if (true)\n" + "    stmt;\n" + "else|\n");
156:                indentNewLine();
157:                assertDocumentTextAndCaret("Incorrect new-line indent",
158:                        "if (true)\n" + "    stmt;\n" + "else\n" + "    |\n");
159:            }
160:
161:            public void testEnterAfterIfElseStmt() {
162:                setLoadDocumentText("if (true)\n" + "    stmt;\n" + "else\n"
163:                        + "    stmt;|\n");
164:                indentNewLine();
165:                assertDocumentTextAndCaret("Incorrect new-line indent",
166:                        "if (true)\n" + "    stmt;\n" + "else\n"
167:                                + "    stmt;\n" + "|\n");
168:            }
169:
170:            public void testEnterAfterIfMultiLine() {
171:                setLoadDocumentText("if (1 < 5|\n");
172:                indentNewLine();
173:                assertDocumentTextAndCaret("Incorrect new-line indent",
174:                        "if (1 < 5\n" + "        |\n");
175:            }
176:
177:            public void testEnterAfterIfMultiLine2() {
178:                setLoadDocumentText("if (1 < 5|)\n");
179:                indentNewLine();
180:                assertDocumentTextAndCaret("Incorrect new-line indent",
181:                        "if (1 < 5\n" + "        |)\n");
182:            }
183:
184:            /**
185:             * Test reformatting of unbalanced braces
186:             * @see http://www.netbeans.org/issues/show_bug.cgi?id=91561
187:             */
188:            public void testIdentUnbalancedBraces() {
189:                setLoadDocumentText("void foo() {\n" + "#if A\n"
190:                        + "    if (0) {\n" + "#else\n" + "    if (1) {\n"
191:                        + "#endif|\n" + "    }\n" + "}\n");
192:                indentNewLine();
193:                assertDocumentText("Incorrect identing of unbalanced braces",
194:                        "void foo() {\n" + "#if A\n" + "    if (0) {\n"
195:                                + "#else\n" + "    if (1) {\n" + "#endif\n"
196:                                + "        \n" + "    }\n" + "}\n");
197:            }
198:
199:            /**
200:             * Test reformatting of unbalanced braces
201:             * @see http://www.netbeans.org/issues/show_bug.cgi?id=91561
202:             */
203:            public void testIdentUnbalancedBraces2() {
204:                setLoadDocumentText("void foo() {\n" + "#if A\n"
205:                        + "    if (0) {\n" + "#else\n" + "    if (1) {\n"
206:                        + "#endif\n" + "    }|\n" + "}\n");
207:                indentNewLine();
208:                assertDocumentText("Incorrect identing of unbalanced braces",
209:                        "void foo() {\n" + "#if A\n" + "    if (0) {\n"
210:                                + "#else\n" + "    if (1) {\n" + "#endif\n"
211:                                + "    }\n" + "    \n" + "}\n");
212:            }
213:
214:            //    /**
215:            //     * Test reformatting of unbalanced braces
216:            //     * @see http://www.netbeans.org/issues/show_bug.cgi?id=91561
217:            //     */
218:            //    public void testIdentUnbalancedBraces3() {
219:            //        setLoadDocumentText(
220:            //            "void foo() {\n" +
221:            //            "#if A\n" +
222:            //            "    if (0) {\n" +
223:            //            "#else\n" +
224:            //            "    if (1) {\n" +
225:            //            "#endif\n" +
226:            //            "    }\n" +
227:            //            "|}\n");
228:            //        indentNewLine();
229:            //        assertDocumentText("Incorrect identing of unbalanced braces",
230:            //            "void foo() {\n" +
231:            //            "#if A\n" +
232:            //            "    if (0) {\n" +
233:            //            "#else\n" +
234:            //            "    if (1) {\n" +
235:            //            "#endif\n" +
236:            //            "    }\n" +
237:            //            "\n" + 
238:            //            "}\n");
239:            //    }
240:
241:            /**
242:             * Test reformatting of unbalanced braces
243:             * @see http://www.netbeans.org/issues/show_bug.cgi?id=97305
244:             */
245:            public void testIdentMain() {
246:                setCppEditorKit(false);
247:                setLoadDocumentText("int main() {|\n");
248:                indentNewLine();
249:                assertDocumentText("Incorrect identing of main",
250:                        "int main() {\n" + "    \n");
251:            }
252:
253:            public void testIZ101099() {
254:                setLoadDocumentText("template <class T>|\n");
255:                indentNewLine();
256:                assertDocumentTextAndCaret(
257:                        "Incorrect new-line indent IZ101099",
258:                        "template <class T>\n" + "|\n");
259:            }
260:
261:            public void testIZ122489() {
262:                setLoadDocumentText("Cpu::Cpu(int units) :\n"
263:                        + "   Module(units) {\n" + "}|\n");
264:                indentNewLine();
265:                assertDocumentTextAndCaret(
266:                        "Incorrect new-line indent IZ122489",
267:                        "Cpu::Cpu(int units) :\n" + "   Module(units) {\n"
268:                                + "}\n" + "|\n");
269:            }
270:
271:            /**
272:             * test parameter aligning
273:             */
274:            public void testIdentMethodParameters() {
275:                setCppEditorKit(false);
276:                setLoadDocumentText("int longmain(int a,|\n");
277:                indentNewLine();
278:                assertDocumentText("Incorrect identing of main",
279:                        "int longmain(int a,\n" + "        \n");
280:            }
281:
282:            /**
283:             * test parameter aligning
284:             */
285:            public void testIdentMethodParameters2() {
286:                EditorOptions.getPreferences(
287:                        CodeStyle.getDefault(CodeStyle.Language.C)).putBoolean(
288:                        EditorOptions.alignMultilineMethodParams, true);
289:                try {
290:                    setCppEditorKit(false);
291:                    setLoadDocumentText("int longmain(int a,|\n");
292:                    indentNewLine();
293:                    assertDocumentText("Incorrect identing of main",
294:                            "int longmain(int a,\n" + "             \n");
295:                } finally {
296:                    EditorOptions.getPreferences(
297:                            CodeStyle.getDefault(CodeStyle.Language.C))
298:                            .putBoolean(
299:                                    EditorOptions.alignMultilineMethodParams,
300:                                    false);
301:                }
302:            }
303:
304:            /**
305:             * test parameter aligning
306:             */
307:            public void testIdentCallParameters() {
308:                setCppEditorKit(false);
309:                setLoadDocumentText("a = longmain(a,|\n");
310:                indentNewLine();
311:                assertDocumentText("Incorrect identing of main",
312:                        "a = longmain(a,\n" + "        \n");
313:            }
314:
315:            /**
316:             * test parameter aligning
317:             */
318:            public void testIdentCallParameters2() {
319:                EditorOptions.getPreferences(
320:                        CodeStyle.getDefault(CodeStyle.Language.CPP))
321:                        .putBoolean(EditorOptions.alignMultilineCallArgs, true);
322:                try {
323:                    setLoadDocumentText("a = longmain(a,|\n");
324:                    indentNewLine();
325:                    assertDocumentText("Incorrect identing of main",
326:                            "a = longmain(a,\n" + "             \n");
327:                } finally {
328:                    EditorOptions.getPreferences(
329:                            CodeStyle.getDefault(CodeStyle.Language.CPP))
330:                            .putBoolean(EditorOptions.alignMultilineCallArgs,
331:                                    false);
332:                }
333:            }
334:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.