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: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.cnd.completion.cplusplus.hyperlink;
043:
044: /**
045: *
046: * @author Vladimir Voskresensky
047: */
048: public class NamespacesHyperlinkTestCase extends HyperlinkBaseTestCase {
049:
050: public NamespacesHyperlinkTestCase(String testName) {
051: super (testName);
052: //System.setProperty("cnd.modelimpl.trace.registration", "true");
053: }
054:
055: public void testS1FooDefFQN() throws Exception {
056: performTest("file.cc", 9, 10, "file.cc", 4, 1); // S1 in S1::foo();
057: performTest("file.cc", 9, 14, "file.cc", 7, 5); // foo in S1::foo();
058: performTest("file.cc", 10, 10, "file.cc", 4, 1); // S1 in S1::var1();
059: performTest("file.cc", 10, 14, "file.cc", 5, 5); // var1 in S1::var1;
060:
061: performTest("file.cc", 14, 10, "file.cc", 4, 1); // S1 in S1::S2::boo();
062: performTest("file.cc", 14, 14, "file.cc", 20, 5); // S2 in S1::S2::boo();
063: performTest("file.cc", 14, 18, "file.cc", 23, 9); // boo in S1::S2::boo();
064: performTest("file.cc", 15, 10, "file.cc", 4, 1); // S1 in S1::S2::var2();
065: performTest("file.cc", 15, 14, "file.cc", 20, 5); // S2 in S1::S2::var2();
066: performTest("file.cc", 15, 18, "file.cc", 21, 9); // var2 in S1::S2::var2();
067: }
068:
069: public void testS2BooDefFQN() throws Exception {
070: performTest("file.cc", 25, 14, "file.cc", 4, 1); // S1 in S1::foo();
071: performTest("file.cc", 25, 18, "file.cc", 7, 5); // foo in S1::foo();
072: performTest("file.cc", 26, 14, "file.cc", 4, 1); // S1 in S1::var1();
073: performTest("file.cc", 26, 18, "file.cc", 5, 5); // var1 in S1::var1;
074:
075: performTest("file.cc", 30, 14, "file.cc", 4, 1); // S1 in S1::S2::boo();
076: performTest("file.cc", 30, 18, "file.cc", 20, 5); // S2 in S1::S2::boo();
077: performTest("file.cc", 30, 22, "file.cc", 23, 9); // boo in S1::S2::boo();
078: performTest("file.cc", 31, 14, "file.cc", 4, 1); // S1 in S1::S2::var2;
079: performTest("file.cc", 31, 18, "file.cc", 20, 5); // S2 in S1::S2::var2;
080: performTest("file.cc", 31, 22, "file.cc", 21, 9); // var2 in S1::S2::var2;
081: }
082:
083: public void testMainDefFQN() throws Exception {
084: performTest("main.cc", 6, 6, "file.cc", 4, 1); // S1 in S1::foo();
085: performTest("main.cc", 6, 10, "file.cc", 7, 5); // foo in S1::foo();
086: performTest("main.cc", 7, 6, "file.cc", 4, 1); // S1 in S1::var1();
087: performTest("main.cc", 7, 10, "file.cc", 5, 5); // var1 in S1::var1;
088:
089: performTest("main.cc", 8, 6, "file.cc", 4, 1); // S1 in S1::S2::boo();
090: performTest("main.cc", 8, 10, "file.cc", 20, 5); // S2 in S1::S2::boo();
091: performTest("main.cc", 8, 14, "file.cc", 23, 9); // boo in S1::S2::boo();
092: performTest("main.cc", 9, 6, "file.cc", 4, 1); // S1 in S1::S2::var2;
093: performTest("main.cc", 9, 10, "file.cc", 20, 5); // S2 in S1::S2::var2;
094: performTest("main.cc", 9, 14, "file.cc", 21, 9); // var2 in S1::S2::var2;
095: }
096:
097: public void testS1FooDefS1Decls() throws Exception {
098: performTest("file.cc", 11, 10, "file.cc", 7, 5); // foo();
099: performTest("file.cc", 12, 10, "file.cc", 5, 5); // var1
100: }
101:
102: public void testS2BooDefS1Decls() throws Exception {
103: performTest("file.cc", 27, 14, "file.cc", 7, 5); // foo();
104: performTest("file.cc", 28, 14, "file.cc", 5, 5); // var1
105: }
106:
107: public void testS1FooDefS2() throws Exception {
108: performTest("file.cc", 16, 10, "file.cc", 20, 5); // S2 in S2::boo();
109: performTest("file.cc", 16, 14, "file.cc", 23, 9); // boo in S2::boo();
110: performTest("file.cc", 17, 10, "file.cc", 20, 5); // S2 in S2::var2
111: performTest("file.cc", 17, 14, "file.cc", 21, 9); // var2 in S2::var2
112: }
113:
114: public void testS2BooDefS2Decls() throws Exception {
115: performTest("file.cc", 32, 14, "file.cc", 20, 5); // S2 in S2::boo();
116: performTest("file.cc", 32, 18, "file.cc", 23, 9); // boo in S2::boo();
117: performTest("file.cc", 33, 14, "file.cc", 20, 5); // S2 in S2::var2
118: performTest("file.cc", 33, 18, "file.cc", 21, 9); // var2 in S2::var2
119: performTest("file.cc", 34, 14, "file.cc", 23, 9); // boo
120: performTest("file.cc", 35, 14, "file.cc", 21, 9); // var2
121: }
122:
123: public void testDeclsFromHeader() throws Exception {
124: performTest("file.h", 6, 17, "file.cc", 5, 5); // extern int var1;
125: performTest("file.h", 7, 11, "file.cc", 7, 5); // void foo();
126: performTest("file.h", 9, 22, "file.cc", 21, 9); // extern int var2;
127: performTest("file.h", 10, 15, "file.cc", 23, 9); // void boo();
128: }
129:
130: public void testClassS1() throws Exception {
131: performTest("file.cc", 39, 14, "file.h", 18, 5); // clsS1 s1;
132: performTest("file.cc", 40, 20, "file.cc", 59, 5); // clsS1pubFun in s1.clsS1pubFun();
133: performTest("file.cc", 52, 10, "file.h", 18, 5); // clsS1 s1;
134: performTest("file.cc", 53, 15, "file.cc", 59, 5); // clsS1pubFun in s1.clsS1pubFun();
135: performTest("file.cc", 59, 14, "file.h", 18, 5); // clsS1 in void clsS1::clsS1pubFun() {
136: performTest("file.cc", 59, 20, "file.h", 20, 9); // clsS1pubFun in void clsS1::clsS1pubFun() {
137: performTest("file.h", 20, 20, "file.cc", 59, 5); // void clsS1pubFun();
138: }
139:
140: public void testClassS2() throws Exception {
141: performTest("file.cc", 42, 14, "file.h", 12, 9); // clsS2 s2;
142: performTest("file.cc", 43, 20, "file.cc", 46, 9); // clsS2pubFun in s2.clsS2pubFun();
143: performTest("file.cc", 55, 14, "file.h", 12, 9); // clsS2 s2;
144: performTest("file.cc", 46, 18, "file.h", 12, 9); // clsS2 in void clsS2::clsS2pubFun() {
145: performTest("file.cc", 46, 25, "file.h", 14, 13); // clsS2pubFun in void clsS2::clsS2pubFun() {
146: performTest("file.h", 14, 25, "file.cc", 46, 9); // void clsS2pubFun();
147: }
148:
149: public void testUnnamed() throws Exception {
150: performTest("unnamed.cc", 5, 6, "unnamed.h", 16, 5);// funFromUnnamed();
151: performTest("unnamed.cc", 6, 6, "unnamed.h", 11, 5);// unnamedAInt = 10;
152: performTest("unnamed.cc", 7, 6, "unnamed.h", 7, 5);// ClUnnamedA in ClUnnamedA cl;
153: performTest("unnamed.cc", 8, 10, "unnamed.h", 9, 9);// funFromClassA in cl.funFromClassA();
154: performTest("unnamed.cc", 9, 6, "unnamed.h", 13, 5);// funDefFromUnnamed();
155:
156: performTest("unnamed.h", 6, 12, "unnamed.h", 16, 5);// void funDefFromUnnamed();
157: }
158:
159: public void testUsingNS1() throws Exception {
160: performTest("main.cc", 15, 6, "file.cc", 5, 5); //var1 = 10;
161: performTest("main.cc", 16, 6, "file.cc", 7, 5); //foo();
162: performTest("main.cc", 17, 6, "file.h", 18, 5); //clsS1 in clsS1 c1;
163: performTest("main.cc", 18, 10, "file.cc", 59, 5); //clsS1pubFun in c1.clsS1pubFun();
164: }
165:
166: public void testUsingNS1S2() throws Exception {
167: performTest("main.cc", 23, 6, "file.cc", 21, 9); //var2 = 10;
168: performTest("main.cc", 24, 6, "file.cc", 23, 9); //boo();
169: performTest("main.cc", 25, 6, "file.h", 12, 9); //clsS2 in clsS2 c2;
170: performTest("main.cc", 26, 10, "file.cc", 46, 9); //clsS2pubFun in c2.clsS2pubFun();
171: }
172:
173: public void testUsingDirectivesS1() throws Exception {
174: performTest("main.cc", 31, 6, "file.h", 18, 5); //clsS1 in clsS1 c1;
175: performTest("main.cc", 33, 6, "file.cc", 5, 5); //var1 = 10;
176: performTest("main.cc", 35, 6, "file.cc", 7, 5); //foo();
177: }
178:
179: public void testUsingDirectivesS1S2() throws Exception {
180: performTest("main.cc", 40, 6, "file.h", 12, 9); //clsS2 in clsS2 c2;
181: performTest("main.cc", 42, 6, "file.cc", 21, 9); //var2 = 10;
182: performTest("main.cc", 44, 6, "file.cc", 23, 9); //boo();
183: }
184:
185: public void testUsingCout() throws Exception {
186: performTest("main.cc", 69, 10, "file.cc", 63, 5); //myCout in S1::myCout;
187: performTest("main.cc", 70, 20, "file.cc", 63, 5); //myCout in using S1::myCout;
188: performTest("main.cc", 71, 6, "file.cc", 63, 5); //myCout;
189: }
190:
191: public void testUsingNS2() throws Exception {
192: // IZ#106772: incorrect resolving of using directive
193: performTest("main.cc", 51, 6, "file.cc", 21, 9); //var2 = 10;
194: performTest("main.cc", 52, 6, "file.cc", 23, 9); //boo();
195: performTest("main.cc", 53, 6, "file.h", 12, 9); //clsS2 in clsS2 c2;
196: }
197:
198: public void testUsingDirectivesS2() throws Exception {
199: // IZ#106772: incorrect resolving of using directive
200: performTest("main.cc", 61, 6, "file.h", 12, 9); //clsS2 in clsS2 c2;
201: performTest("main.cc", 63, 6, "file.cc", 21, 9); //var2 = 10;
202: performTest("main.cc", 65, 6, "file.cc", 23, 9); //boo();
203: }
204:
205: public static class Failed extends HyperlinkBaseTestCase {
206:
207: protected Class getTestCaseDataClass() {
208: return NamespacesHyperlinkTestCase.class;
209: }
210:
211: public Failed(String testName) {
212: super (testName);
213: }
214:
215: public void testClassS2FunInFunS1() throws Exception {
216: performTest("file.cc", 56, 20, "file.h", 14, 13); // clsS2pubFun in s2.clsS2pubFun();
217: }
218:
219: public void testUsingNS2() throws Exception {
220: performTest("main.cc", 54, 10, "file.cc", 46, 9); //clsS2pubFun in c2.clsS2pubFun();
221: }
222: }
223: }
|