diff options
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CommentCheckerLineTests.java')
-rw-r--r-- | codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CommentCheckerLineTests.java | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CommentCheckerLineTests.java b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CommentCheckerLineTests.java new file mode 100644 index 00000000000..b2fe1557964 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.test/src/org/eclipse/cdt/codan/core/internal/checkers/CommentCheckerLineTests.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2015 QNX Software System and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Elena Laskavaia (QNX Software System) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.core.internal.checkers; + +import java.io.File; + +import org.eclipse.cdt.codan.core.test.CheckerTestCase; +import org.eclipse.cdt.codan.internal.checkers.CommentChecker; +import org.junit.Test; + +/** + * Tests for CommentChecker + */ +public class CommentCheckerLineTests extends CheckerTestCase { + @Override + public void setUp() throws Exception { + super.setUp(); + enableProblems(CommentChecker.COMMENT_NO_LINE); + } + + // void foo() { + // return; // error + // } + @Test + public void testLineComment() { + checkSampleAbove(); + } + + // void foo() { + // return; + // } + @Test + public void testNoLineComment() { + checkSampleAbove(); + } + + // char * foo() { + // return "// this is a string"; + // } + @Test + public void testNoLineCommentInString() { + checkSampleAbove(); + } + + // void foo() { + // return; // not an error in c++ + // } + @Test + public void testLineCommentCpp() { + checkSampleAboveCpp(); + } + + // #define AAA // error even in prepro + @Test + public void testLineCommentInPrepro() { + checkSampleAbove(); + } + + // @file:test.h + // int foo();// error too + + + // @file:test.c + // #include "test.h" + // int bar() { + // foo(); + // } + public void testHeader() throws Exception { + loadcode(getContents(2)); + runOnProject(); + checkErrorLine(new File("test.h"), 1); //$NON-NLS-1$ + } +} |