From 8fb26410f558162ea455b10aca1ee0c38c915f43 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Wed, 25 Apr 2007 07:22:02 +0000 Subject: [PATCH] Testcase for bug 183930, comments in inactive code. --- .../core/parser/tests/ast2/CommentTests.java | 20 +++++++++++++++++++ .../parser/tests/ast2/DOMParserTestSuite.java | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java index 534c5be879a..4e8e98bcf3d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/CommentTests.java @@ -11,6 +11,8 @@ ******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import junit.framework.TestSuite; + import org.eclipse.cdt.core.dom.ast.IASTComment; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.parser.ParserLanguage; @@ -22,6 +24,10 @@ import org.eclipse.cdt.internal.core.parser.ParserException; */ public class CommentTests extends AST2BaseTest { + public static TestSuite suite() { + return suite(CommentTests.class); + } + public void testCountCommentsInHeaderFile() throws ParserException{ IASTTranslationUnit tu = parse(getHSource(), ParserLanguage.CPP, false, true, true); IASTComment[] comments = tu.getComments(); @@ -188,4 +194,18 @@ public class CommentTests extends AST2BaseTest { return buffer.toString(); } + // #ifdef xxx + // // comment1 + // #else + // // comment2 + // #endif + public void _testCommentsInInactiveCode_bug183930() throws Exception { + StringBuffer code= getContents(1)[0]; + IASTTranslationUnit tu = parse(code.toString(), ParserLanguage.CPP, false, true, true); + IASTComment[] comments = tu.getComments(); + + assertEquals(2, comments.length); + assertEquals("// comment1", new String(comments[0].getComment())); + assertEquals("// comment2", new String(comments[0].getComment())); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java index 5bd6bc1a083..89dd50c4317 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMParserTestSuite.java @@ -47,7 +47,7 @@ public class DOMParserTestSuite extends TestCase { suite.addTestSuite( DOMSelectionParseTest.class ); suite.addTestSuite( GCCCompleteParseExtensionsTest.class ); suite.addTestSuite(DOMPreprocessorInformationTest.class); - suite.addTestSuite(CommentTests.class); + suite.addTest(CommentTests.suite()); suite.addTest( CompletionTestSuite.suite() ); return suite; }