View | Details | Raw Unified | Return to bug 100568 | Differences between
and this patch

Collapse All | Expand All

(-)ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsCTagsIndexer.java (-43 / +19 lines)
Lines 142-156 Link Here
142
			assertEquals(((TextSelection)def).getOffset(), header.indexOf("int x() { return 1; }\n"));
142
			assertEquals(((TextSelection)def).getOffset(), header.indexOf("int x() { return 1; }\n"));
143
			assertEquals(((TextSelection)def).getLength(), "int x() { return 1; }\n".length());
143
			assertEquals(((TextSelection)def).getLength(), "int x() { return 1; }\n".length());
144
		}
144
		}
145
		try {
145
		ISelection decl = testF3Selection(file, offset);
146
			// TODO raised bug 97079
146
		if (decl instanceof TextSelection) {
147
			ISelection decl = testF3Selection(file, offset);
147
			assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int x() { return 1; }\n"));
148
			if (decl instanceof TextSelection) {
148
			assertEquals(((TextSelection)decl).getLength(), "int x() { return 1; }\n".length());
149
				assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int x() { return 1; }\n"));
149
		}
150
				assertEquals(((TextSelection)decl).getLength(), "int x() { return 1; }\n".length());
151
			}
152
			assertFalse(true); // when this fails then the test is passing correctly
153
		} catch (AssertionFailedError afe) {}
154
	}
150
	}
155
151
156
	public void testSimpleOpenDeclaration2() throws Exception {
152
	public void testSimpleOpenDeclaration2() throws Exception {
Lines 165-179 Link Here
165
			assertEquals(((TextSelection)def).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
161
			assertEquals(((TextSelection)def).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
166
			assertEquals(((TextSelection)def).getLength(), "int y() { return 1; }\r\n".length());
162
			assertEquals(((TextSelection)def).getLength(), "int y() { return 1; }\r\n".length());
167
		}
163
		}
168
		try {
164
		ISelection decl = testF3Selection(file, offset);
169
			// TODO raised bug 97079
165
		if (decl instanceof TextSelection) {
170
			ISelection decl = testF3Selection(file, offset);
166
			assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
171
			if (decl instanceof TextSelection) {
167
			assertEquals(((TextSelection)decl).getLength(), "int y() { return 1; }\r\n".length());
172
				assertEquals(((TextSelection)decl).getOffset(), header.indexOf("int y() { return 1; }\r\n"));
168
		}		
173
				assertEquals(((TextSelection)decl).getLength(), "int y() { return 1; }\r\n".length());
174
			}		
175
			assertFalse(true); // when this fails then the test is passing correctly
176
		} catch (AssertionFailedError afe) {}
177
	}
169
	}
178
	
170
	
179
	// perform the tests from CSelectionTestsNoIndexer and make sure they work with an indexer as well:
171
	// perform the tests from CSelectionTestsNoIndexer and make sure they work with an indexer as well:
Lines 549-558 Link Here
549
		offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
541
		offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
550
        def = testF2(file, offset);
542
        def = testF2(file, offset);
551
        decl = testF3(file, offset);
543
        decl = testF3(file, offset);
552
        try {
544
       	assertNull(def);
553
        	assertNull(def); // TODO raised bug 96689
554
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
555
        } catch (AssertionFailedError e) {}
556
545
557
        assertTrue(decl instanceof IASTName);
546
        assertTrue(decl instanceof IASTName);
558
        assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
547
        assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
Lines 574-583 Link Here
574
        int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
563
        int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
575
        IASTNode def = testF2(file, offset);
564
        IASTNode def = testF2(file, offset);
576
        IASTNode decl = testF3(file, offset);
565
        IASTNode decl = testF3(file, offset);
577
        try {
566
       	assertNull(def);
578
        	assertNull(def); // TODO raised bug 96689
579
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
580
        } catch (AssertionFailedError e) {}
581
567
582
        assertTrue(decl instanceof IASTName);
568
        assertTrue(decl instanceof IASTName);
583
        assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
569
        assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
Lines 587-596 Link Here
587
		offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
573
		offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
588
        def = testF2(file, offset);
574
        def = testF2(file, offset);
589
        decl = testF3(file, offset);
575
        decl = testF3(file, offset);
590
        try {
576
       	assertNull(def);
591
        	assertNull(def); // TODO raised bug 96689
592
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
593
        } catch (AssertionFailedError e) {}
594
        assertTrue(decl instanceof IASTName);
577
        assertTrue(decl instanceof IASTName);
595
        assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
578
        assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
596
        assertEquals(((ASTNode)decl).getOffset(), 46);
579
        assertEquals(((ASTNode)decl).getOffset(), 46);
Lines 608-617 Link Here
608
		offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
591
		offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
609
        def = testF2(file, offset);
592
        def = testF2(file, offset);
610
        decl = testF3(file, offset);
593
        decl = testF3(file, offset);
611
        try {
594
       	assertNull(def);
612
        	assertNull(def); // TODO raised bug 96690
613
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
614
        } catch (AssertionFailedError e) {}
615
        assertTrue(decl instanceof IASTName);
595
        assertTrue(decl instanceof IASTName);
616
        assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
596
        assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
617
        assertEquals(((ASTNode)decl).getOffset(), 98);
597
        assertEquals(((ASTNode)decl).getOffset(), 98);
Lines 643-657 Link Here
643
			assertEquals(((TextSelection)def).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n")); //$NON-NLS-1$
623
			assertEquals(((TextSelection)def).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n")); //$NON-NLS-1$
644
			assertEquals(((TextSelection)def).getLength(), " int y() { return 1; } /* comment */ \r\n".length()); //$NON-NLS-1$
624
			assertEquals(((TextSelection)def).getLength(), " int y() { return 1; } /* comment */ \r\n".length()); //$NON-NLS-1$
645
		}
625
		}
646
		try {
626
		ISelection decl = testF3Selection(file, offset);
647
			// TODO raised bug 97079
627
		if (decl instanceof TextSelection) {
648
			ISelection decl = testF3Selection(file, offset);
628
			assertEquals(((TextSelection)decl).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n"));
649
			if (decl instanceof TextSelection) {
629
			assertEquals(((TextSelection)decl).getLength(), " int y() { return 1; } /* comment */ \r\n".length());
650
				assertEquals(((TextSelection)decl).getOffset(), header.indexOf(" int y() { return 1; } /* comment */ \r\n"));
630
		}		
651
				assertEquals(((TextSelection)decl).getLength(), " int y() { return 1; } /* comment */ \r\n".length());
652
			}		
653
			assertFalse(true); // when this fails then the test is passing correctly
654
		} catch (AssertionFailedError afe) {}
655
	}
631
	}
656
	
632
	
657
    // REMINDER: see CSelectionTestsCTagsIndexer#suite() when appending new tests to this suite
633
    // REMINDER: see CSelectionTestsCTagsIndexer#suite() when appending new tests to this suite
(-)ui/org/eclipse/cdt/ui/tests/text/selectiontests/CSelectionTestsDOMIndexer.java (-37 / +13 lines)
Lines 132-144 Link Here
132
		
132
		
133
		int offset = code.indexOf("x();\n}\n");
133
		int offset = code.indexOf("x();\n}\n");
134
		IASTNode def = testF2(file, offset);
134
		IASTNode def = testF2(file, offset);
135
		try {
135
		assertTrue(def instanceof IASTName);
136
			// TODO raised bug 97079
136
		assertEquals(((ASTNode)def).getOffset(), header.indexOf("x")); //$NON-NLS-1$
137
			assertTrue(def instanceof IASTName);
137
		assertEquals(((ASTNode)def).getLength(), "x".length()); //$NON-NLS-1$
138
			assertEquals(((ASTNode)def).getOffset(), header.indexOf("x")); //$NON-NLS-1$
139
			assertEquals(((ASTNode)def).getLength(), "x".length()); //$NON-NLS-1$
140
			assertTrue(false); // when this fails then the test is passing correctly
141
		} catch (AssertionFailedError afe) {}
142
		IASTNode decl = testF3(file, offset);
138
		IASTNode decl = testF3(file, offset);
143
		assertTrue(decl instanceof IASTName);
139
		assertTrue(decl instanceof IASTName);
144
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("x")); //$NON-NLS-1$
140
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("x")); //$NON-NLS-1$
Lines 154-166 Link Here
154
		
150
		
155
		int offset = code.indexOf("y();\n}\n");
151
		int offset = code.indexOf("y();\n}\n");
156
		IASTNode def = testF2(file, offset);
152
		IASTNode def = testF2(file, offset);
157
		try {
153
		assertTrue(def instanceof IASTName);
158
			// TODO raised bug 97079
154
		assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
159
			assertTrue(def instanceof IASTName);
155
		assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
160
			assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
161
			assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
162
			assertTrue(false); // when this fails then the test is passing correctly
163
		} catch (AssertionFailedError afe) {}
164
		IASTNode decl = testF3(file, offset);
156
		IASTNode decl = testF3(file, offset);
165
		assertTrue(decl instanceof IASTName);
157
		assertTrue(decl instanceof IASTName);
166
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$
158
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$
Lines 541-550 Link Here
541
		offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
533
		offset = code.indexOf("anotherX; // declares anotherX"); //$NON-NLS-1$
542
        def = testF2(file, offset);
534
        def = testF2(file, offset);
543
        decl = testF3(file, offset);
535
        decl = testF3(file, offset);
544
        try {
536
       	assertNull(def);
545
        	assertNull(def); // TODO raised bug 96689
546
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
547
        } catch (AssertionFailedError e) {}
548
537
549
        assertTrue(decl instanceof IASTName);
538
        assertTrue(decl instanceof IASTName);
550
        assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
539
        assertEquals(((IASTName)decl).toString(), "anotherX"); //$NON-NLS-1$
Lines 566-575 Link Here
566
        int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
555
        int offset = code.indexOf("a1; // declares a"); //$NON-NLS-1$
567
        IASTNode def = testF2(file, offset);
556
        IASTNode def = testF2(file, offset);
568
        IASTNode decl = testF3(file, offset);
557
        IASTNode decl = testF3(file, offset);
569
        try {
558
       	assertNull(def);
570
        	assertNull(def); // TODO raised bug 96689
571
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
572
        } catch (AssertionFailedError e) {}
573
559
574
        assertTrue(decl instanceof IASTName);
560
        assertTrue(decl instanceof IASTName);
575
        assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
561
        assertEquals(((IASTName)decl).toString(), "a1"); //$NON-NLS-1$
Lines 579-588 Link Here
579
		offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
565
		offset = code.indexOf("c1; // declares c"); //$NON-NLS-1$
580
        def = testF2(file, offset);
566
        def = testF2(file, offset);
581
        decl = testF3(file, offset);
567
        decl = testF3(file, offset);
582
        try {
568
       	assertNull(def);
583
        	assertNull(def); // TODO raised bug 96689
584
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
585
        } catch (AssertionFailedError e) {}
586
        assertTrue(decl instanceof IASTName);
569
        assertTrue(decl instanceof IASTName);
587
        assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
570
        assertEquals(((IASTName)decl).toString(), "c1"); //$NON-NLS-1$
588
        assertEquals(((ASTNode)decl).getOffset(), 46);
571
        assertEquals(((ASTNode)decl).getOffset(), 46);
Lines 600-609 Link Here
600
		offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
583
		offset = code.indexOf("S1; // declares S"); //$NON-NLS-1$
601
        def = testF2(file, offset);
584
        def = testF2(file, offset);
602
        decl = testF3(file, offset);
585
        decl = testF3(file, offset);
603
        try {
586
       	assertNull(def);
604
        	assertNull(def); // TODO raised bug 96690
605
        	assertTrue(false); // try/catch/assertTrue(false) added to alert the tester when this test passes!
606
        } catch (AssertionFailedError e) {}
607
        assertTrue(decl instanceof IASTName);
587
        assertTrue(decl instanceof IASTName);
608
        assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
588
        assertEquals(((IASTName)decl).toString(), "S1"); //$NON-NLS-1$
609
        assertEquals(((ASTNode)decl).getOffset(), 98);
589
        assertEquals(((ASTNode)decl).getOffset(), 98);
Lines 631-643 Link Here
631
		
611
		
632
		int offset = code.indexOf("y();\n}\n");
612
		int offset = code.indexOf("y();\n}\n");
633
		IASTNode def = testF2(file, offset);
613
		IASTNode def = testF2(file, offset);
634
		try {
614
		assertTrue(def instanceof IASTName);
635
			// TODO raised bug 97079
615
		assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
636
			assertTrue(def instanceof IASTName);
616
		assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
637
			assertEquals(((ASTNode)def).getOffset(), header.indexOf("y")); //$NON-NLS-1$
638
			assertEquals(((ASTNode)def).getLength(), "y".length()); //$NON-NLS-1$
639
			assertTrue(false); // when this fails then the test is passing correctly
640
		} catch (AssertionFailedError afe) {}
641
		IASTNode decl = testF3(file, offset);
617
		IASTNode decl = testF3(file, offset);
642
		assertTrue(decl instanceof IASTName);
618
		assertTrue(decl instanceof IASTName);
643
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$
619
		assertEquals(((ASTNode)decl).getOffset(), header.indexOf("y")); //$NON-NLS-1$

Return to bug 100568