diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java index e5bb16e3e30..9fc51bc0dfb 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/builder/tests/CDataProviderTests.java @@ -13,12 +13,16 @@ *******************************************************************************/ package org.eclipse.cdt.make.builder.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.make.core.MakeCorePlugin; +import org.eclipse.cdt.make.tests.BaseTestCase; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IResource; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java index 05420461a8e..7af77b14fd5 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/BaseBOPConsoleParserTests.java @@ -15,12 +15,16 @@ *******************************************************************************/ package org.eclipse.cdt.make.scannerdiscovery; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoConsoleParser; import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; +import org.eclipse.cdt.make.tests.BaseTestCase; import junit.framework.TestSuite; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java index 3d93c1a498d..c941848c888 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCPerFileBOPConsoleParserTests.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.cdt.make.scannerdiscovery; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import java.util.List; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java index 6a93be0ed96..29ab1abe99c 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/GCCScannerInfoConsoleParserTests.java @@ -15,6 +15,8 @@ *******************************************************************************/ package org.eclipse.cdt.make.scannerdiscovery; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java index 16cbee69872..0d724a23769 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigDiscoveryTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.make.scannerdiscovery; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.io.ByteArrayInputStream; import java.util.Arrays; import java.util.List; @@ -22,13 +25,12 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.parser.IScannerInfo; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.MakeProjectNature; import org.eclipse.cdt.make.core.scannerconfig.ScannerConfigNature; import org.eclipse.cdt.make.core.tests.StandardBuildTestHelper; import org.eclipse.cdt.make.internal.core.scannerconfig2.PerProjectSICollector; +import org.eclipse.cdt.make.tests.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigProfileTests.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigProfileTests.java index 86ff9f3929c..c7a943ac88e 100644 --- a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigProfileTests.java +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/scannerdiscovery/ScannerConfigProfileTests.java @@ -16,11 +16,11 @@ import java.io.ByteArrayInputStream; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.make.core.tests.StandardBuildTestHelper; import org.eclipse.cdt.make.internal.core.scannerconfig2.ScannerConfigProfileManager; +import org.eclipse.cdt.make.tests.BaseTestCase; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Assert; diff --git a/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/tests/BaseTestCase.java b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/tests/BaseTestCase.java new file mode 100644 index 00000000000..d77b0914b8c --- /dev/null +++ b/build/org.eclipse.cdt.make.core.tests/src/org/eclipse/cdt/make/tests/BaseTestCase.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.make.tests; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.IVariable; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.eclipse.cdt.core.testplugin.util.LogMonitoring; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.cdt.internal.core.pdom.CModelListener; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +/** + * @deprecated Please migrate tests away from JUnit3 style to JUnit5 style by using {@link BaseTestCase5} + * as base class. + */ +@Deprecated +public abstract class BaseTestCase extends TestCase { + private static final String DEFAULT_INDEXER_TIMEOUT_SEC = BaseTestCase5.DEFAULT_INDEXER_TIMEOUT_SEC; + private static final String INDEXER_TIMEOUT_PROPERTY = BaseTestCase5.INDEXER_TIMEOUT_PROPERTY; + /** + * Indexer timeout used by tests. To avoid this timeout expiring during debugging add + * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. + */ + protected static final int INDEXER_TIMEOUT_SEC = BaseTestCase5.INDEXER_TIMEOUT_SEC; + protected static final int INDEXER_TIMEOUT_MILLISEC = BaseTestCase5.INDEXER_TIMEOUT_MILLISEC; + + /** + * The GCC version to emulate when running tests. + * We emulate the latest version whose extensions we support. + */ + protected static final int GCC_MAJOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MAJOR_VERSION_FOR_TESTS; + protected static final int GCC_MINOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MINOR_VERSION_FOR_TESTS; + + /** + * This provides the systems new line separator. Use this if you do String comparisons in tests + * instead of hard coding '\n' or '\r\n' respectively. + */ + protected static final String NL = BaseTestCase5.NL; + + private boolean fExpectFailure; + private int fBugNumber; + private int fExpectedLoggedNonOK; + private Deque filesToDeleteOnTearDown = new ArrayDeque<>(); + + public BaseTestCase() { + super(); + } + + public BaseTestCase(String name) { + super(name); + } + + public static NullProgressMonitor npm() { + return new NullProgressMonitor(); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + CPPASTNameBase.sAllowRecursionBindings = false; + CPPASTNameBase.sAllowNameComputation = false; + CModelListener.sSuppressUpdateOfLastRecentlyUsed = true; + } + + @Override + protected void tearDown() throws Exception { + for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) { + file.delete(); + } + ResourceHelper.cleanUp(getName()); + TestScannerProvider.clear(); + BaseTestCase5.assertWorkspaceIsEmpty(); + super.tearDown(); + } + + protected void deleteOnTearDown(File file) { + filesToDeleteOnTearDown.add(file); + } + + protected File createTempFile(String prefix, String suffix) throws IOException { + File file = File.createTempFile(prefix, suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected File nonExistentTempFile(String prefix, String suffix) { + File file = new File(System.getProperty("java.io.tmpdir"), prefix + System.currentTimeMillis() + suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected static TestSuite suite(Class clazz) { + return suite(clazz, null); + } + + protected static TestSuite suite(Class clazz, String failingTestPrefix) { + TestSuite suite = new TestSuite(clazz); + Test failing = getFailingTests(clazz, failingTestPrefix); + if (failing != null) { + suite.addTest(failing); + } + return suite; + } + + private static Test getFailingTests(Class clazz, String prefix) { + TestSuite suite = new TestSuite("Failing Tests"); + HashSet names = new HashSet(); + Class superClass = clazz; + while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) { + Method[] methods = superClass.getDeclaredMethods(); + for (Method method : methods) { + addFailingMethod(suite, method, names, clazz, prefix); + } + superClass = superClass.getSuperclass(); + } + if (suite.countTestCases() == 0) { + return null; + } + return suite; + } + + private static void addFailingMethod(TestSuite suite, Method m, Set names, Class clazz, String prefix) { + String name = m.getName(); + if (!names.add(name)) { + return; + } + if (name.startsWith("test") || (prefix != null && !name.startsWith(prefix))) { + return; + } + if (name.equals("tearDown") || name.equals("setUp") || name.equals("runBare")) { + return; + } + if (Modifier.isPublic(m.getModifiers())) { + Class[] parameters = m.getParameterTypes(); + Class returnType = m.getReturnType(); + if (parameters.length == 0 && returnType.equals(Void.TYPE)) { + Test test = TestSuite.createTest(clazz, name); + ((BaseTestCase) test).setExpectFailure(0); + suite.addTest(test); + } + } + } + + @Override + public void runBare() throws Throwable { + LogMonitoring monitoring = new LogMonitoring(); + monitoring.start(); + try { + super.runBare(); + } finally { + monitoring.stop(fExpectedLoggedNonOK); + } + } + + @Override + public void run(TestResult result) { + if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) { + super.run(result); + return; + } + + result.startTest(this); + + TestResult r = new TestResult(); + super.run(r); + if (r.failureCount() == 1) { + TestFailure failure = r.failures().nextElement(); + String msg = failure.exceptionMessage(); + if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { + result.addFailure(this, new AssertionFailedError(msg)); + } + } else if (r.errorCount() == 0 && r.failureCount() == 0) { + String err = "Unexpected success of " + getName(); + if (fBugNumber > 0) { + err += ", bug #" + fBugNumber; + } + result.addFailure(this, new AssertionFailedError(err)); + } + + result.endTest(this); + } + + public void setExpectFailure(int bugNumber) { + fExpectFailure = true; + fBugNumber = bugNumber; + } + + /** + * The last value passed to this method in the body of a testXXX method + * will be used to determine whether or not the presence of non-OK status objects + * in the log should fail the test. If the logged number of non-OK status objects + * differs from the last value passed, the test is failed. If this method is not called + * at all, the expected number defaults to zero. + * @param count the expected number of logged error and warning messages + */ + public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) { + fExpectedLoggedNonOK = count; + } + + public static void waitForIndexer(ICProject project) throws InterruptedException { + BaseTestCase5.waitForIndexer(project); + } + + public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { + BaseTestCase5.waitUntilFileIsIndexed(index, file); + } + + // Assertion helpers (redirected to the common implementation) + + protected static T assertInstance(Object o, Class clazz, Class... cs) { + return BaseTestCase5.assertInstance(o, clazz, cs); + } + + protected static void assertValue(IValue value, long expectedValue) { + BaseTestCase5.assertValue(value, expectedValue); + } + + protected static void assertVariableValue(IVariable var, long expectedValue) { + BaseTestCase5.assertVariableValue(var, expectedValue); + } + + protected static String formatForPrinting(IASTName name) { + return BaseTestCase5.formatForPrinting(name); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java index 86010f1ab0a..298263a2fb5 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/suite/org/eclipse/cdt/managedbuilder/tests/suite/ManagedBuilderPreconditionsTests.java @@ -13,12 +13,15 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.tests.suite; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.Arrays; import java.util.Set; import java.util.TreeSet; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.utils.PathUtil; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java index a2e09593c3b..c5be4c5d12a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/CfgScannerConfigProfileManagerTests.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.build.core.scannerconfig.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Map; import org.eclipse.cdt.build.core.scannerconfig.CfgInfoContext; @@ -23,10 +25,10 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.make.core.scannerconfig.IScannerConfigBuilderInfo2; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Assert; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/GCCSpecsConsoleParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/GCCSpecsConsoleParserTest.java index 05b106f22bf..c8435cadacf 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/GCCSpecsConsoleParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/build/core/scannerconfig/tests/GCCSpecsConsoleParserTest.java @@ -13,13 +13,16 @@ *******************************************************************************/ package org.eclipse.cdt.build.core.scannerconfig.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import java.util.Map; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.make.core.scannerconfig.IScannerInfoCollector; import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes; import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCSpecsConsoleParser; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; public class GCCSpecsConsoleParserTest extends BaseTestCase { GCCSpecsConsoleParser parser; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BaseTestCase.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BaseTestCase.java new file mode 100644 index 00000000000..3cce2a40c76 --- /dev/null +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BaseTestCase.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.managedbuilder.core.tests; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.IVariable; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.eclipse.cdt.core.testplugin.util.LogMonitoring; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.cdt.internal.core.pdom.CModelListener; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +/** + * @deprecated Please migrate tests away from JUnit3 style to JUnit5 style by using {@link BaseTestCase5} + * as base class. + */ +@Deprecated +public abstract class BaseTestCase extends TestCase { + private static final String DEFAULT_INDEXER_TIMEOUT_SEC = BaseTestCase5.DEFAULT_INDEXER_TIMEOUT_SEC; + private static final String INDEXER_TIMEOUT_PROPERTY = BaseTestCase5.INDEXER_TIMEOUT_PROPERTY; + /** + * Indexer timeout used by tests. To avoid this timeout expiring during debugging add + * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. + */ + protected static final int INDEXER_TIMEOUT_SEC = BaseTestCase5.INDEXER_TIMEOUT_SEC; + protected static final int INDEXER_TIMEOUT_MILLISEC = BaseTestCase5.INDEXER_TIMEOUT_MILLISEC; + + /** + * The GCC version to emulate when running tests. + * We emulate the latest version whose extensions we support. + */ + protected static final int GCC_MAJOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MAJOR_VERSION_FOR_TESTS; + protected static final int GCC_MINOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MINOR_VERSION_FOR_TESTS; + + /** + * This provides the systems new line separator. Use this if you do String comparisons in tests + * instead of hard coding '\n' or '\r\n' respectively. + */ + protected static final String NL = BaseTestCase5.NL; + + private boolean fExpectFailure; + private int fBugNumber; + private int fExpectedLoggedNonOK; + private Deque filesToDeleteOnTearDown = new ArrayDeque<>(); + + public BaseTestCase() { + super(); + } + + public BaseTestCase(String name) { + super(name); + } + + public static NullProgressMonitor npm() { + return new NullProgressMonitor(); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + CPPASTNameBase.sAllowRecursionBindings = false; + CPPASTNameBase.sAllowNameComputation = false; + CModelListener.sSuppressUpdateOfLastRecentlyUsed = true; + } + + @Override + protected void tearDown() throws Exception { + for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) { + file.delete(); + } + ResourceHelper.cleanUp(getName()); + TestScannerProvider.clear(); + BaseTestCase5.assertWorkspaceIsEmpty(); + super.tearDown(); + } + + protected void deleteOnTearDown(File file) { + filesToDeleteOnTearDown.add(file); + } + + protected File createTempFile(String prefix, String suffix) throws IOException { + File file = File.createTempFile(prefix, suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected File nonExistentTempFile(String prefix, String suffix) { + File file = new File(System.getProperty("java.io.tmpdir"), prefix + System.currentTimeMillis() + suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected static TestSuite suite(Class clazz) { + return suite(clazz, null); + } + + protected static TestSuite suite(Class clazz, String failingTestPrefix) { + TestSuite suite = new TestSuite(clazz); + Test failing = getFailingTests(clazz, failingTestPrefix); + if (failing != null) { + suite.addTest(failing); + } + return suite; + } + + private static Test getFailingTests(Class clazz, String prefix) { + TestSuite suite = new TestSuite("Failing Tests"); + HashSet names = new HashSet(); + Class superClass = clazz; + while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) { + Method[] methods = superClass.getDeclaredMethods(); + for (Method method : methods) { + addFailingMethod(suite, method, names, clazz, prefix); + } + superClass = superClass.getSuperclass(); + } + if (suite.countTestCases() == 0) { + return null; + } + return suite; + } + + private static void addFailingMethod(TestSuite suite, Method m, Set names, Class clazz, String prefix) { + String name = m.getName(); + if (!names.add(name)) { + return; + } + if (name.startsWith("test") || (prefix != null && !name.startsWith(prefix))) { + return; + } + if (name.equals("tearDown") || name.equals("setUp") || name.equals("runBare")) { + return; + } + if (Modifier.isPublic(m.getModifiers())) { + Class[] parameters = m.getParameterTypes(); + Class returnType = m.getReturnType(); + if (parameters.length == 0 && returnType.equals(Void.TYPE)) { + Test test = TestSuite.createTest(clazz, name); + ((BaseTestCase) test).setExpectFailure(0); + suite.addTest(test); + } + } + } + + @Override + public void runBare() throws Throwable { + LogMonitoring monitoring = new LogMonitoring(); + monitoring.start(); + try { + super.runBare(); + } finally { + monitoring.stop(fExpectedLoggedNonOK); + } + } + + @Override + public void run(TestResult result) { + if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) { + super.run(result); + return; + } + + result.startTest(this); + + TestResult r = new TestResult(); + super.run(r); + if (r.failureCount() == 1) { + TestFailure failure = r.failures().nextElement(); + String msg = failure.exceptionMessage(); + if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { + result.addFailure(this, new AssertionFailedError(msg)); + } + } else if (r.errorCount() == 0 && r.failureCount() == 0) { + String err = "Unexpected success of " + getName(); + if (fBugNumber > 0) { + err += ", bug #" + fBugNumber; + } + result.addFailure(this, new AssertionFailedError(err)); + } + + result.endTest(this); + } + + public void setExpectFailure(int bugNumber) { + fExpectFailure = true; + fBugNumber = bugNumber; + } + + /** + * The last value passed to this method in the body of a testXXX method + * will be used to determine whether or not the presence of non-OK status objects + * in the log should fail the test. If the logged number of non-OK status objects + * differs from the last value passed, the test is failed. If this method is not called + * at all, the expected number defaults to zero. + * @param count the expected number of logged error and warning messages + */ + public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) { + fExpectedLoggedNonOK = count; + } + + public static void waitForIndexer(ICProject project) throws InterruptedException { + BaseTestCase5.waitForIndexer(project); + } + + public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { + BaseTestCase5.waitUntilFileIsIndexed(index, file); + } + + // Assertion helpers (redirected to the common implementation) + + protected static T assertInstance(Object o, Class clazz, Class... cs) { + return BaseTestCase5.assertInstance(o, clazz, cs); + } + + protected static void assertValue(IValue value, long expectedValue) { + BaseTestCase5.assertValue(value, expectedValue); + } + + protected static void assertVariableValue(IVariable var, long expectedValue) { + BaseTestCase5.assertVariableValue(var, expectedValue); + } + + protected static String formatForPrinting(IASTName name) { + return BaseTestCase5.formatForPrinting(name); + } +} diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java index a8dd1232f80..33a0f22fb5f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildDescriptionModelTests.java @@ -29,7 +29,6 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.buildmodel.BuildDescriptionManager; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildDescription; import org.eclipse.cdt.managedbuilder.buildmodel.IBuildIOType; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildSystem40Tests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildSystem40Tests.java index a9b19c2f060..433a5ac6660 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildSystem40Tests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/BuildSystem40Tests.java @@ -29,7 +29,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java index 720549ade59..aa193e3d747 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCoreTests.java @@ -17,7 +17,6 @@ import java.util.Arrays; import java.util.List; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java index c65383716c9..39a24773cf3 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildCore_SharedToolOptionsTests.java @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedOptionValueHandler; import org.eclipse.cdt.managedbuilder.core.IManagedProject; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java index d5714bc2fa1..22823edd1a2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildDependencyCalculatorTests.java @@ -22,7 +22,6 @@ import java.io.FileFilter; import java.util.ArrayList; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.projectconverter.UpdateManagedProjectManager; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java index d64bf77d1aa..8567b9e929e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildEnvironmentTests.java @@ -16,7 +16,6 @@ import org.eclipse.cdt.core.envvar.IEnvironmentVariable; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java index d4134e26b0e..ec19bf08b78 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildMacrosTests.java @@ -22,7 +22,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.ICDescriptor; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildTCSupportedTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildTCSupportedTest.java index 9446240a387..b7c17e07418 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildTCSupportedTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedBuildTCSupportedTest.java @@ -15,7 +15,6 @@ package org.eclipse.cdt.managedbuilder.core.tests; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedProject; import org.eclipse.cdt.managedbuilder.core.IProjectType; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java index 7f08725a203..9c699cc9dbf 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedCommandLineGeneratorTest.java @@ -17,7 +17,6 @@ import java.util.ArrayList; import java.util.Arrays; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java index 55162342cfb..bc985f6eb21 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ManagedProject30MakefileTests.java @@ -24,7 +24,6 @@ import java.nio.file.Files; import java.util.ArrayList; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IAdditionalInput; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IInputType; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionCategoryEnablementTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionCategoryEnablementTests.java index 7fb7e14ad62..77cf3569d88 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionCategoryEnablementTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionCategoryEnablementTests.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.core.tests; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IConfiguration; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionEnablementTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionEnablementTests.java index 5f212d3f1c6..2b76e08c98a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionEnablementTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/OptionEnablementTests.java @@ -15,7 +15,6 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IConfiguration; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/PathConverterTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/PathConverterTest.java index f1ff67e3fba..9cfd5c79ead 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/PathConverterTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/PathConverterTest.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.managedbuilder.core.tests; import org.eclipse.cdt.core.model.IPathEntry; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.model.IncludeEntry; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java index 0cb5a683f51..cf745849f9f 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ResourceBuildCoreTests.java @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java index 429083b2f46..59e4954d610 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/core/tests/ToolChainModificationTests.java @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.util.CDataUtil; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IBuildObject; import org.eclipse.cdt.managedbuilder.core.IBuilder; import org.eclipse.cdt.managedbuilder.core.IConfiguration; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java index c59788f7cf0..2e60d77c82d 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/BuiltinSpecsDetectorTest.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import java.io.OutputStream; import java.net.URI; @@ -43,11 +49,11 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager; import org.eclipse.cdt.internal.core.envvar.UserDefinedEnvironmentSupplier; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuiltinSpecsDetector; import org.eclipse.cdt.utils.envvar.StorableEnvironment; import org.eclipse.core.resources.IProject; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java index a67532ca43c..cc06db01843 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/CompilationDatabaseParserTest.java @@ -10,8 +10,13 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.ByteArrayInputStream; import java.io.FileReader; @@ -40,8 +45,8 @@ import org.eclipse.cdt.core.settings.model.ICSourceEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.CompilationDatabaseParser; import org.eclipse.cdt.managedbuilder.internal.language.settings.providers.CompileCommand; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java index e4b6f892b6e..a409389af6b 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/GCCBuildCommandParserTest.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.net.URI; import java.util.ArrayList; import java.util.HashMap; @@ -41,10 +47,10 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.language.settings.providers.AbstractBuildCommandParser; import org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser; import org.eclipse.core.resources.IFile; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java index ed4a013fdf8..684eb90ab61 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/managedbuilder/language/settings/providers/tests/LanguageSettingsProvidersMBSTest.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.managedbuilder.language.settings.providers.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; @@ -25,8 +29,8 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/BackwardCompatiblityTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/BackwardCompatiblityTests.java index c0ee78c7c6b..2a607c5988e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/BackwardCompatiblityTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/BackwardCompatiblityTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.projectmodel.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + import java.util.Iterator; import java.util.LinkedList; import java.util.List; @@ -21,7 +24,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.testplugin.ManagedBuildTestHelper; import org.eclipse.core.resources.IProject; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java index f7abc73ef3c..8c5dcbadbc1 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/OptionStringListValueTests.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.cdt.projectmodel.tests; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; @@ -31,7 +37,6 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.BuildException; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IFolderInfo; @@ -39,6 +44,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.cdt.managedbuilder.core.OptionStringValue; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.testplugin.BuildSystemTestHelper; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java index 08ab09ed54d..243f6982291 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/tests/org/eclipse/cdt/projectmodel/tests/ProjectModelTests.java @@ -14,6 +14,13 @@ *******************************************************************************/ package org.eclipse.cdt.projectmodel.tests; +import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.util.ArrayList; import java.util.Arrays; @@ -40,13 +47,13 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CLanguageData; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IFileInfo; import org.eclipse.cdt.managedbuilder.core.IFolderInfo; import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IResourceInfo; import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.cdt.managedbuilder.core.tests.BaseTestCase; import org.eclipse.cdt.managedbuilder.internal.core.Configuration; import org.eclipse.cdt.managedbuilder.internal.core.ManagedBuildInfo; import org.eclipse.cdt.managedbuilder.internal.core.ManagedProject; diff --git a/build/org.eclipse.cdt.managedbuilder.ui/OSGI-INF/org.eclipse.cdt.managedbuilder.internal.ui.compilationdatabase.PreferenceConfigurationAccess.xml b/build/org.eclipse.cdt.managedbuilder.ui/OSGI-INF/org.eclipse.cdt.managedbuilder.internal.ui.compilationdatabase.PreferenceConfigurationAccess.xml index 378faf3f27d..45f61850759 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/OSGI-INF/org.eclipse.cdt.managedbuilder.internal.ui.compilationdatabase.PreferenceConfigurationAccess.xml +++ b/build/org.eclipse.cdt.managedbuilder.ui/OSGI-INF/org.eclipse.cdt.managedbuilder.internal.ui.compilationdatabase.PreferenceConfigurationAccess.xml @@ -5,6 +5,6 @@ - + \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/BaseTestCase.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/BaseTestCase.java new file mode 100644 index 00000000000..6ead89b2760 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/BaseTestCase.java @@ -0,0 +1,261 @@ +/******************************************************************************* + * Copyright (c) 2006, 2016 Wind River Systems, Inc. and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Markus Schorn - initial API and implementation + * Andrew Ferguson (Symbian) + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.codan.core.tests; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.IVariable; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.ResourceHelper; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.eclipse.cdt.core.testplugin.util.LogMonitoring; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase; +import org.eclipse.cdt.internal.core.pdom.CModelListener; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; + +/** + * @deprecated Please migrate tests away from JUnit3 style to JUnit5 style by using {@link BaseTestCase5} + * as base class. + */ +@Deprecated +public abstract class BaseTestCase extends TestCase { + private static final String DEFAULT_INDEXER_TIMEOUT_SEC = BaseTestCase5.DEFAULT_INDEXER_TIMEOUT_SEC; + private static final String INDEXER_TIMEOUT_PROPERTY = BaseTestCase5.INDEXER_TIMEOUT_PROPERTY; + /** + * Indexer timeout used by tests. To avoid this timeout expiring during debugging add + * -Dindexer.timeout=some_large_number to VM arguments of the test launch configuration. + */ + protected static final int INDEXER_TIMEOUT_SEC = BaseTestCase5.INDEXER_TIMEOUT_SEC; + protected static final int INDEXER_TIMEOUT_MILLISEC = BaseTestCase5.INDEXER_TIMEOUT_MILLISEC; + + /** + * The GCC version to emulate when running tests. + * We emulate the latest version whose extensions we support. + */ + protected static final int GCC_MAJOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MAJOR_VERSION_FOR_TESTS; + protected static final int GCC_MINOR_VERSION_FOR_TESTS = BaseTestCase5.GCC_MINOR_VERSION_FOR_TESTS; + + /** + * This provides the systems new line separator. Use this if you do String comparisons in tests + * instead of hard coding '\n' or '\r\n' respectively. + */ + protected static final String NL = BaseTestCase5.NL; + + private boolean fExpectFailure; + private int fBugNumber; + private int fExpectedLoggedNonOK; + private Deque filesToDeleteOnTearDown = new ArrayDeque<>(); + + public BaseTestCase() { + super(); + } + + public BaseTestCase(String name) { + super(name); + } + + public static NullProgressMonitor npm() { + return new NullProgressMonitor(); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + CPPASTNameBase.sAllowRecursionBindings = false; + CPPASTNameBase.sAllowNameComputation = false; + CModelListener.sSuppressUpdateOfLastRecentlyUsed = true; + } + + @Override + protected void tearDown() throws Exception { + for (File file; (file = filesToDeleteOnTearDown.pollLast()) != null;) { + file.delete(); + } + ResourceHelper.cleanUp(getName()); + TestScannerProvider.clear(); + BaseTestCase5.assertWorkspaceIsEmpty(); + super.tearDown(); + } + + protected void deleteOnTearDown(File file) { + filesToDeleteOnTearDown.add(file); + } + + protected File createTempFile(String prefix, String suffix) throws IOException { + File file = File.createTempFile(prefix, suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected File nonExistentTempFile(String prefix, String suffix) { + File file = new File(System.getProperty("java.io.tmpdir"), prefix + System.currentTimeMillis() + suffix); + filesToDeleteOnTearDown.add(file); + return file; + } + + protected static TestSuite suite(Class clazz) { + return suite(clazz, null); + } + + protected static TestSuite suite(Class clazz, String failingTestPrefix) { + TestSuite suite = new TestSuite(clazz); + Test failing = getFailingTests(clazz, failingTestPrefix); + if (failing != null) { + suite.addTest(failing); + } + return suite; + } + + private static Test getFailingTests(Class clazz, String prefix) { + TestSuite suite = new TestSuite("Failing Tests"); + HashSet names = new HashSet(); + Class superClass = clazz; + while (Test.class.isAssignableFrom(superClass) && !TestCase.class.equals(superClass)) { + Method[] methods = superClass.getDeclaredMethods(); + for (Method method : methods) { + addFailingMethod(suite, method, names, clazz, prefix); + } + superClass = superClass.getSuperclass(); + } + if (suite.countTestCases() == 0) { + return null; + } + return suite; + } + + private static void addFailingMethod(TestSuite suite, Method m, Set names, Class clazz, String prefix) { + String name = m.getName(); + if (!names.add(name)) { + return; + } + if (name.startsWith("test") || (prefix != null && !name.startsWith(prefix))) { + return; + } + if (name.equals("tearDown") || name.equals("setUp") || name.equals("runBare")) { + return; + } + if (Modifier.isPublic(m.getModifiers())) { + Class[] parameters = m.getParameterTypes(); + Class returnType = m.getReturnType(); + if (parameters.length == 0 && returnType.equals(Void.TYPE)) { + Test test = TestSuite.createTest(clazz, name); + ((BaseTestCase) test).setExpectFailure(0); + suite.addTest(test); + } + } + } + + @Override + public void runBare() throws Throwable { + LogMonitoring monitoring = new LogMonitoring(); + monitoring.start(); + try { + super.runBare(); + } finally { + monitoring.stop(fExpectedLoggedNonOK); + } + } + + @Override + public void run(TestResult result) { + if (!fExpectFailure || Boolean.parseBoolean(System.getProperty("SHOW_EXPECTED_FAILURES"))) { + super.run(result); + return; + } + + result.startTest(this); + + TestResult r = new TestResult(); + super.run(r); + if (r.failureCount() == 1) { + TestFailure failure = r.failures().nextElement(); + String msg = failure.exceptionMessage(); + if (msg != null && msg.startsWith("Method \"" + getName() + "\"")) { + result.addFailure(this, new AssertionFailedError(msg)); + } + } else if (r.errorCount() == 0 && r.failureCount() == 0) { + String err = "Unexpected success of " + getName(); + if (fBugNumber > 0) { + err += ", bug #" + fBugNumber; + } + result.addFailure(this, new AssertionFailedError(err)); + } + + result.endTest(this); + } + + public void setExpectFailure(int bugNumber) { + fExpectFailure = true; + fBugNumber = bugNumber; + } + + /** + * The last value passed to this method in the body of a testXXX method + * will be used to determine whether or not the presence of non-OK status objects + * in the log should fail the test. If the logged number of non-OK status objects + * differs from the last value passed, the test is failed. If this method is not called + * at all, the expected number defaults to zero. + * @param count the expected number of logged error and warning messages + */ + public void setExpectedNumberOfLoggedNonOKStatusObjects(int count) { + fExpectedLoggedNonOK = count; + } + + public static void waitForIndexer(ICProject project) throws InterruptedException { + BaseTestCase5.waitForIndexer(project); + } + + public static void waitUntilFileIsIndexed(IIndex index, IFile file) throws Exception { + BaseTestCase5.waitUntilFileIsIndexed(index, file); + } + + // Assertion helpers (redirected to the common implementation) + + protected static T assertInstance(Object o, Class clazz, Class... cs) { + return BaseTestCase5.assertInstance(o, clazz, cs); + } + + protected static void assertValue(IValue value, long expectedValue) { + BaseTestCase5.assertValue(value, expectedValue); + } + + protected static void assertVariableValue(IVariable var, long expectedValue) { + BaseTestCase5.assertVariableValue(var, expectedValue); + } + + protected static String formatForPrinting(IASTName name) { + return BaseTestCase5.formatForPrinting(name); + } +} diff --git a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java index d6989fe3746..08bac387f93 100644 --- a/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java +++ b/codan/org.eclipse.cdt.codan.core.tests/src/org/eclipse/cdt/codan/core/tests/CodanTestCase.java @@ -26,7 +26,6 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; import org.eclipse.cdt.core.testplugin.util.ModelJoiner; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.core.resources.IFile; diff --git a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs index afec999c9e1..523bc391368 100644 --- a/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs +++ b/core/org.eclipse.cdt.core.tests/.settings/org.eclipse.jdt.core.prefs @@ -1,4 +1,5 @@ eclipse.preferences.version=1 +org.eclipse.jdt.core.builder.annotationPath.allLocations=disabled org.eclipse.jdt.core.builder.cleanOutputFolder=clean org.eclipse.jdt.core.builder.duplicateResourceTask=warning org.eclipse.jdt.core.builder.invalidClasspath=abort @@ -25,9 +26,12 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonN org.eclipse.jdt.core.compiler.annotation.nonnull.secondary= org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary= +org.eclipse.jdt.core.compiler.annotation.notowning=org.eclipse.jdt.annotation.NotOwning org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable org.eclipse.jdt.core.compiler.annotation.nullable.secondary= org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning +org.eclipse.jdt.core.compiler.annotation.resourceanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=generate org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 @@ -39,6 +43,7 @@ org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.doc.comment.support=enabled org.eclipse.jdt.core.compiler.maxProblemPerUnit=100 org.eclipse.jdt.core.compiler.problem.APILeak=warning +org.eclipse.jdt.core.compiler.problem.annotatedTypeArgumentToUnannotated=info org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.autoboxing=ignore @@ -61,8 +66,10 @@ org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompatibleOwningContract=warning org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.insufficientResourceAnalysis=warning org.eclipse.jdt.core.compiler.problem.invalidJavadoc=ignore org.eclipse.jdt.core.compiler.problem.invalidJavadocTags=enabled org.eclipse.jdt.core.compiler.problem.invalidJavadocTagsDeprecatedRef=disabled @@ -113,6 +120,7 @@ org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning @@ -136,13 +144,14 @@ org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverridin org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedImport=warning org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLambdaParameter=warning org.eclipse.jdt.core.compiler.problem.unusedLocal=ignore org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled -org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=ignore +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning diff --git a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF index ac42fc23d47..045bfb8e621 100644 --- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF @@ -35,8 +35,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests, org.eclipse.cdt.utils Require-Bundle: org.eclipse.core.resources;bundle-version="[3.22.200,4)", org.eclipse.cdt.core;bundle-version="[9.1.0,10)", - org.junit;bundle-version="[4.13.2,5)", - org.eclipse.jdt.junit4.runtime;bundle-version="[1.3.100,2)", org.eclipse.core.runtime;bundle-version="[3.33.0,4)", org.eclipse.ui.ide;bundle-version="[3.22.600,4)", org.eclipse.ui;bundle-version="[3.207.200,4)", diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java index 18323a5b0cf..f8a25f0d730 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/LanguageInheritanceTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.language; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; + import java.util.Collections; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -25,18 +30,19 @@ import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.CContentTypes; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.content.IContentType; - -import junit.framework.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for language inheritance computations. */ -public class LanguageInheritanceTests extends BaseTestCase { +public class LanguageInheritanceTests extends BaseTestCase5 { private static final String BIN_FOLDER = "bin"; private static final String FILE_NAME = "test.c"; @@ -51,12 +57,8 @@ public class LanguageInheritanceTests extends BaseTestCase { private IProject fProject; private ICConfigurationDescription fConfiguration; - public static Test suite() { - return suite(LanguageInheritanceTests.class); - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { String name = getClass().getName() + "_" + getName(); fCProject = CProjectHelper.createCCProject(name, BIN_FOLDER, IPDOMManager.ID_NO_INDEXER); fProject = fCProject.getProject(); @@ -75,11 +77,12 @@ protected void setUp() throws Exception { fManager.storeWorkspaceLanguageConfiguration(EMPTY_CONTENT_TYPES); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { CProjectHelper.delete(fCProject); } + @Test public void testDirectFileMapping() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); @@ -96,6 +99,7 @@ public void testDirectFileMapping() throws Exception { assertSameLanguage(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration)); } + @Test public void testDirectProjectContentTypeMapping() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); @@ -114,6 +118,7 @@ public void testDirectProjectContentTypeMapping() throws Exception { assertSameLanguage(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration)); } + @Test public void testDirectWorkspaceContentTypeMapping() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); @@ -132,6 +137,7 @@ public void testDirectWorkspaceContentTypeMapping() throws Exception { assertEquals(originalLanguage, fManager.getLanguageForFile(fFile, fConfiguration)); } + @Test public void testOverriddenWorkspaceContentTypeMapping1() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); @@ -152,6 +158,7 @@ public void testOverriddenWorkspaceContentTypeMapping1() throws Exception { assertSameLanguage(fLanguage2, fManager.getLanguageForFile(fFile, fConfiguration)); } + @Test public void testOverriddenWorkspaceContentTypeMapping2() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); @@ -172,6 +179,7 @@ public void testOverriddenWorkspaceContentTypeMapping2() throws Exception { assertSameLanguage(fLanguage2, fManager.getLanguageForFile(fFile, fConfiguration)); } + @Test public void testOverriddenProjectContentTypeMapping() throws Exception { ILanguage originalLanguage = fManager.getLanguageForFile(fFile, fConfiguration); assertDifferentLanguages(originalLanguage, fLanguage1); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java index ead0274c84a..67e04f242ce 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsExtensionsTests.java @@ -14,6 +14,14 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -27,19 +35,18 @@ import org.eclipse.cdt.core.settings.model.CMacroFileEntry; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICSettingEntry; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsExtensionManager; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Path; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Test cases testing LanguageSettingsProvider extensions */ -public class LanguageSettingsExtensionsTests extends BaseTestCase { +public class LanguageSettingsExtensionsTests extends BaseTestCase5 { // These should match corresponding entries defined in plugin.xml /*package*/ static final String EXTENSION_BASE_PROVIDER_ID = "org.eclipse.cdt.core.tests.language.settings.base.provider"; /*package*/ static final String EXTENSION_BASE_PROVIDER_NAME = "Test Plugin Mock Language Settings Base Provider"; @@ -72,44 +79,10 @@ public class LanguageSettingsExtensionsTests extends BaseTestCase { private static final String ATTR_NAME = LanguageSettingsProvidersSerializer.ATTR_NAME; private static final String ATTR_CLASS = LanguageSettingsProvidersSerializer.ATTR_CLASS; - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsExtensionsTests(String name) { - super(name); - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsExtensionsTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - /** * Check that regular {@link ICLanguageSettingsProvider} extension defined in plugin.xml is accessible. */ + @Test public void testExtension() throws Exception { { // test provider defined as an extension @@ -118,8 +91,8 @@ public void testExtension() throws Exception { for (ILanguageSettingsProvider provider : providers) { ids.add(provider.getId()); } - assertTrue("extension " + EXTENSION_BASE_PROVIDER_ID + " not found", - ids.contains(EXTENSION_BASE_PROVIDER_ID)); + assertTrue(ids.contains(EXTENSION_BASE_PROVIDER_ID), + "extension " + EXTENSION_BASE_PROVIDER_ID + " not found"); } { @@ -165,7 +138,7 @@ public void testExtension() throws Exception { // retrieve entries from extension point List actual = provider.getSettingEntries(null, FILE_0, EXTENSION_BASE_PROVIDER_LANG_ID); for (int i = 0; i < entriesExt.size(); i++) { - assertEquals("i=" + i, entriesExt.get(i), actual.get(i)); + assertEquals(entriesExt.get(i), actual.get(i), "i=" + i); } assertEquals(entriesExt.size(), actual.size()); } @@ -173,6 +146,7 @@ public void testExtension() throws Exception { /** * Check that subclassed {@link LanguageSettingsBaseProvider} extension defined in plugin.xml is accessible. */ + @Test public void testExtensionBaseProviderSubclass() throws Exception { // get test plugin extension provider ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager @@ -199,7 +173,7 @@ public void testExtensionBaseProviderSubclass() throws Exception { // retrieve entries from extension point List actual = provider.getSettingEntries(null, FILE_0, LANG_ID); for (int i = 0; i < entriesExt.size(); i++) { - assertEquals("i=" + i, entriesExt.get(i), actual.get(i)); + assertEquals(entriesExt.get(i), actual.get(i), "i=" + i); } assertEquals(entriesExt.size(), actual.size()); } @@ -207,6 +181,7 @@ public void testExtensionBaseProviderSubclass() throws Exception { /** * Make sure extensions contributed through extension point created with proper ID/name. */ + @Test public void testExtensionCustomProvider() throws Exception { // get test plugin extension non-default provider ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager @@ -227,6 +202,7 @@ public void testExtensionCustomProvider() throws Exception { /** * Basic test for {@link LanguageSettingsBaseProvider}. */ + @Test public void testBaseProvider() throws Exception { // define benchmarks List entries = new ArrayList<>(); @@ -262,6 +238,7 @@ public void testBaseProvider() throws Exception { /** * Test ability to configure {@link LanguageSettingsBaseProvider}. */ + @Test public void testBaseProviderConfigure() throws Exception { // sample entries List entries = new ArrayList<>(); @@ -311,6 +288,7 @@ public void testBaseProviderConfigure() throws Exception { /** * {@link LanguageSettingsBaseProvider} is not allowed to be configured twice. */ + @Test public void testBaseProviderCantReconfigure() throws Exception { // create LanguageSettingsBaseProvider LanguageSettingsBaseProvider provider = new LanguageSettingsBaseProvider(); @@ -330,6 +308,7 @@ public void testBaseProviderCantReconfigure() throws Exception { /** * Test {@link LanguageSettingsSerializableProvider} defined via extension point. */ + @Test public void testSerializableProvider() throws Exception { // get test plugin extension for serializable provider ILanguageSettingsProvider providerExtCopy = LanguageSettingsManager @@ -355,6 +334,7 @@ public void testSerializableProvider() throws Exception { /** * Test {@link ILanguageSettingsEditableProvider} defined via extension point. */ + @Test public void testEditableProvider() throws Exception { // Non-editable providers cannot be copied so they are singletons { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java index 687b151cac3..1298a089cbe 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsManagerTests.java @@ -14,6 +14,13 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.List; @@ -27,7 +34,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsProvidersSerializer; import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; import org.eclipse.cdt.internal.core.settings.model.CConfigurationDescription; @@ -38,13 +45,13 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Path; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; /** * Test cases testing {@link LanguageSettingsManager} utility methods. */ -public class LanguageSettingsManagerTests extends BaseTestCase { +public class LanguageSettingsManagerTests extends BaseTestCase5 { // Those should match ids of plugin extensions defined in plugin.xml private static final String EXTENSION_BASE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_BASE_PROVIDER_ID; private static final String EXTENSION_SERIALIZABLE_PROVIDER_ID = LanguageSettingsExtensionsTests.EXTENSION_SERIALIZABLE_PROVIDER_ID; @@ -113,45 +120,15 @@ public List getSettingEntries(ICConfigurationDescription } } - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsManagerTests(String name) { - super(name); - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void tearDownWorkspaceProviders() throws Exception { LanguageSettingsManager.setWorkspaceProviders(null); - super.tearDown(); // includes ResourceHelper cleanup - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsManagerTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); } /** * Test ILanguageSettingsProvidersKeeper API (getters and setters). */ + @Test public void testConfigurationDescription_Providers() throws Exception { // mock configuration description MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -182,6 +159,7 @@ public void testConfigurationDescription_Providers() throws Exception { /** * Test to ensure uniqueness of ids for providers kept in configuration description. */ + @Test public void testConfigurationDescription_ProvidersUniqueId() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); @@ -212,6 +190,7 @@ public void testConfigurationDescription_ProvidersUniqueId() throws Exception { /** * Test various cases of ill-defined providers. */ + @Test public void testRudeProviders() throws Exception { // mock configuration description MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -289,6 +268,7 @@ public List getSettingEntries(ICConfigurationDescription /** * Test assigning and retrieving providers from a configuration. */ + @Test public void testProvider_Basic() throws Exception { final MockConfigurationDescription modelCfgDescription = new MockConfigurationDescription(CFG_ID); @@ -343,6 +323,7 @@ public List getSettingEntries(ICConfigurationDescription /** * Test regular functionality with a few providers. */ + @Test public void testProvider_Regular() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -372,7 +353,7 @@ public void testProvider_Regular() throws Exception { ICLanguageSettingEntry[] entriesArray = entries1.toArray(new ICLanguageSettingEntry[0]); ICLanguageSettingEntry[] actualArray = actual.toArray(new ICLanguageSettingEntry[0]); for (int i = 0; i < entries1.size(); i++) { - assertEquals("i=" + i, entriesArray[i], actualArray[i]); + assertEquals(entriesArray[i], actualArray[i], "i=" + i); } assertEquals(entries1.size(), actual.size()); } @@ -386,7 +367,7 @@ public void testProvider_Regular() throws Exception { ICLanguageSettingEntry[] entriesArray = entries2.toArray(new ICLanguageSettingEntry[0]); ICLanguageSettingEntry[] actualArray = actual.toArray(new ICLanguageSettingEntry[0]); for (int i = 0; i < entries2.size(); i++) { - assertEquals("i=" + i, entriesArray[i], actualArray[i]); + assertEquals(entriesArray[i], actualArray[i], "i=" + i); } assertEquals(entries2.size(), actual.size()); } @@ -395,6 +376,7 @@ public void testProvider_Regular() throws Exception { /** * Test getting entries from resource hierarchy. */ + @Test public void testProvider_ParentFolder() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); @@ -463,6 +445,7 @@ public List getSettingEntries(ICConfigurationDescription /** * Test getting entries from resource hierarchy up to default entries. */ + @Test public void testProvider_DefaultEntries() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); @@ -511,6 +494,7 @@ public List getSettingEntries(ICConfigurationDescription /** * Test ability to get entries by kind. */ + @Test public void testEntriesByKind_Regular() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -545,6 +529,7 @@ public void testEntriesByKind_Regular() throws Exception { /** * Test how conflicting entries are resolved. */ + @Test public void testEntriesByKind_ConflictingEntries() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -569,6 +554,7 @@ public void testEntriesByKind_ConflictingEntries() throws Exception { /** * Check handling of {@link ICSettingEntry#UNDEFINED} flag. */ + @Test public void testEntriesByKind_Undefined() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -591,6 +577,7 @@ public void testEntriesByKind_Undefined() throws Exception { /** * Check handling of local vs. system entries, see {@link ICSettingEntry#LOCAL} flag. */ + @Test public void testEntriesByKind_LocalAndSystem() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -635,6 +622,7 @@ public void testEntriesByKind_LocalAndSystem() throws Exception { /** * Test conflicting entries contributed by different providers. */ + @Test public void testEntriesByKind_ConflictingProviders() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -676,6 +664,7 @@ public void testEntriesByKind_ConflictingProviders() throws Exception { /** * Test ability to get entries by kind. */ + @Test public void testEntriesByKind_CompositeKind() throws Exception { MockConfigurationDescription cfgDescription = new MockConfigurationDescription(CFG_ID); @@ -708,6 +697,7 @@ public void testEntriesByKind_CompositeKind() throws Exception { /** * Test ability to serialize providers for a configuration. */ + @Test public void testConfigurationDescription_SerializeProviders() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); @@ -772,6 +762,7 @@ public void testConfigurationDescription_SerializeProviders() throws Exception { /** * Test a workspace provider basics. */ + @Test public void testWorkspaceProvider_Basic() throws Exception { // get workspace provider ILanguageSettingsProvider provider = LanguageSettingsManager @@ -812,6 +803,7 @@ public void testWorkspaceProvider_Basic() throws Exception { /** * Test workspace providers equality. */ + @Test public void testWorkspaceProvider_Equals() throws Exception { ILanguageSettingsProvider providerA = LanguageSettingsManager .getWorkspaceProvider(EXTENSION_SERIALIZABLE_PROVIDER_ID); @@ -823,6 +815,7 @@ public void testWorkspaceProvider_Equals() throws Exception { /** * Test ability to replace underlying raw provider. */ + @Test public void testWorkspaceProvider_ReplaceRawProvider() throws Exception { // get sample workspace provider ILanguageSettingsProvider provider = LanguageSettingsManager @@ -860,6 +853,7 @@ public void testWorkspaceProvider_ReplaceRawProvider() throws Exception { /** * Test ability to be called with workspace provider as well (NOOP). */ + @Test public void testWorkspaceProvider_ReplaceWithWorkspaceProvider() throws Exception { // get sample workspace provider ILanguageSettingsProvider provider = LanguageSettingsManager diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java index c2825c761d9..01f25dbd0bf 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsPersistenceProjectTests.java @@ -14,10 +14,10 @@ package org.eclipse.cdt.core.language.settings.providers; -import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java index cf6b679525d..5d31736962c 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsProviderReferencedProjectsTests.java @@ -14,6 +14,10 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.HashMap; import java.util.LinkedHashSet; @@ -30,51 +34,16 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.language.settings.providers.ReferencedProjectsLanguageSettingsProvider; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Test cases testing ReferencedProjectsLanguageSettingsProvider functionality */ -public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase { - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsProviderReferencedProjectsTests(String name) { - super(name); - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); // includes ResourceHelper cleanup - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsProviderReferencedProjectsTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } +public class LanguageSettingsProviderReferencedProjectsTests extends BaseTestCase5 { /** * Helper method to fetch configuration descriptions. @@ -131,6 +100,7 @@ private void setReference(IProject project, final IProject projectReferenced) th /** * Test that null arguments don't crash the provider. */ + @Test public void testNulls() throws Exception { ILanguageSettingsProvider provider = LanguageSettingsManager .getWorkspaceProvider(ReferencedProjectsLanguageSettingsProvider.ID); @@ -142,6 +112,7 @@ public void testNulls() throws Exception { /** * Test main functionality of ReferencedProjectsLanguageSettingsProvider. */ + @Test public void testReferencedProjectProvider() throws Exception { // Create model project and accompanied descriptions String projectName = getName(); @@ -228,6 +199,7 @@ public void testReferencedProjectProvider() throws Exception { /** * Test case when projects reference each other recursively. */ + @Test public void testRecursiveReferences() throws Exception { // Create model projects that reference each other String projectName = getName(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java index db0b661bce2..8eb566b36a9 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsScannerInfoProviderTests.java @@ -14,6 +14,11 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -32,7 +37,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.language.settings.providers.LanguageSettingsScannerInfoProvider; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IFile; @@ -43,13 +48,12 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Test cases testing LanguageSettingsProvider functionality */ -public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase { +public class LanguageSettingsScannerInfoProviderTests extends BaseTestCase5 { private static final IFile FAKE_FILE = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/project/path0")); private static final String PROVIDER_ID = "test.provider.id"; private static final String PROVIDER_ID_2 = "test.provider.id.2"; @@ -74,41 +78,6 @@ public List getSettingEntries(ICConfigurationDescription } } - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsScannerInfoProviderTests(String name) { - super(name); - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); // includes ResourceHelper cleanup - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsScannerInfoProviderTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - /** * Sets build working directory for DefaultSettingConfiguration being tested. */ @@ -140,6 +109,7 @@ private void setBuilderCWD(IProject project, IPath buildCWD) throws CoreExceptio /** * Test cases when some objects are null. */ + @Test public void testNulls() throws Exception { { // Handle project==null @@ -200,6 +170,7 @@ public void testNulls() throws Exception { /** * Test empty scanner info. */ + @Test public void testEmpty() throws Exception { LanguageSettingsScannerInfoProvider scannerInfoProvider = new LanguageSettingsScannerInfoProvider(); IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -226,6 +197,7 @@ public void testEmpty() throws Exception { /** * Test regular cases. */ + @Test public void testRegular() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -299,6 +271,7 @@ public void testRegular() throws Exception { /** * Test "local" flag (#include "..."). */ + @Test public void testLocal() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -354,6 +327,7 @@ public void testLocal() throws Exception { /** * Test Mac frameworks. */ + @Test public void testFramework() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -398,6 +372,7 @@ public void testFramework() throws Exception { /** * Test duplicate entries. */ + @Test public void testDuplicate() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -449,6 +424,7 @@ public void testDuplicate() throws Exception { /** * Test include path managed by eclipse as a workspace path. */ + @Test public void testWorkspacePath() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -521,6 +497,7 @@ public void testWorkspacePath() throws Exception { /** * Confirm that device letter is prepended on filesystems that support that. */ + @Test public void testFilesystemPathNoDriveLetter() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -571,6 +548,7 @@ public void testFilesystemPathNoDriveLetter() throws Exception { /** * Test relative paths. */ + @Test public void testRelativePath() throws Exception { // create a project String prjName = getName(); @@ -637,6 +615,7 @@ public void testRelativePath() throws Exception { /** * Test relative paths - some combinations of dot paths. */ + @Test public void testRelativePathWithDots() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -739,6 +718,7 @@ public void testRelativePathWithDots() throws Exception { /** * Test if build/environment variables are expanded */ + @Test public void testEnvironmentVars() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -783,6 +763,7 @@ public void testEnvironmentVars() throws Exception { /** * Test from parent folder's entries. */ + @Test public void testParentFolder() throws Exception { class MockProviderForResource extends LanguageSettingsBaseProvider { private IResource rc; @@ -846,6 +827,7 @@ public List getSettingEntries(ICConfigurationDescription /** * Test resolved paths. */ + @Test public void testResolvedPath() throws Exception { // create a project IProject project = ResourceHelper.createCDTProjectWithConfig(getName()); @@ -910,6 +892,7 @@ private List getLanguages(IFolder folder, ICConfigurationDescription cfg /** * Test composition of 2 languages. */ + @Test public void testResourceLanguages() throws Exception { class MockProviderLang extends LanguageSettingsBaseProvider { private final String langId; diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java index 0eba63f364f..1e2076cdfda 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/language/settings/providers/LanguageSettingsSerializableProviderTests.java @@ -14,6 +14,13 @@ package org.eclipse.cdt.core.language.settings.providers; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; @@ -28,7 +35,7 @@ import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.testplugin.CModelMock; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.XmlUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -36,15 +43,14 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.Element; -import junit.framework.TestSuite; - /** * Test cases testing serialization of LanguageSettingsProviders. */ -public class LanguageSettingsSerializableProviderTests extends BaseTestCase { +public class LanguageSettingsSerializableProviderTests extends BaseTestCase5 { // Arbitrary sample parameters used by the test private static final String CFG_ID = "test.configuration.id"; private static final ICConfigurationDescription MOCK_CFG = new CModelMock.DummyCConfigurationDescription(CFG_ID); @@ -68,44 +74,10 @@ public class LanguageSettingsSerializableProviderTests extends BaseTestCase { // This value must match that of LanguageSettingsProvidersSerializer.ATTR_STORE_ENTRIES_WITH_PROJECT private static final String ATTR_STORE_ENTRIES_WITH_PROJECT = "store-entries-with-project"; - /** - * Constructor. - * @param name - name of the test. - */ - public LanguageSettingsSerializableProviderTests(String name) { - super(name); - - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - } - - @Override - protected void tearDown() throws Exception { - super.tearDown(); // includes ResourceHelper cleanup - } - - /** - * @return - new TestSuite. - */ - public static TestSuite suite() { - return new TestSuite(LanguageSettingsSerializableProviderTests.class); - } - - /** - * main function of the class. - * - * @param args - arguments - */ - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - /** * Test basic methods, getters and setters. */ + @Test public void testProvider_SettersGetters() throws Exception { // benchmark data List entries = new ArrayList<>(); @@ -146,6 +118,7 @@ public void testProvider_SettersGetters() throws Exception { /** * Test property defining whether to store entries in project or workspace area. */ + @Test public void testProvider_SetStoringEntriesInProjectArea() throws Exception { // create a provider LanguageSettingsSerializableProvider provider = new LanguageSettingsSerializableProvider(PROVIDER_1, @@ -161,6 +134,7 @@ public void testProvider_SetStoringEntriesInProjectArea() throws Exception { /** * Check basic serialization. */ + @Test public void testProvider_RegularDOM() throws Exception { Element elementProvider; { @@ -210,6 +184,7 @@ public void testProvider_RegularDOM() throws Exception { /** * Test serialization of properties of the provider. */ + @Test public void testProvider_serializeAttributesDOM() throws Exception { Element elementProvider; { @@ -259,6 +234,7 @@ public void testProvider_serializeAttributesDOM() throws Exception { /** * Test serialization of entries. */ + @Test public void testProvider_serializeEntriesDOM() throws Exception { Element rootElement; { @@ -314,6 +290,7 @@ public void testProvider_serializeEntriesDOM() throws Exception { /** * Test serialization of empty provider. */ + @Test public void testProvider_EmptyDOM() throws Exception { Element elementProvider; { @@ -343,6 +320,7 @@ public void testProvider_EmptyDOM() throws Exception { /** * Test serialization of custom parameter. */ + @Test public void testCustomParameterDOM() throws Exception { Element elementProvider; { @@ -368,6 +346,7 @@ public void testCustomParameterDOM() throws Exception { /** * Test serialization to project area storage. */ + @Test public void testStoreEntriesWithProjectDOM() throws Exception { Element elementProvider; { @@ -395,6 +374,7 @@ public void testStoreEntriesWithProjectDOM() throws Exception { /** * Test serialization of language scope. */ + @Test public void testLanguagesDOM() throws Exception { List expectedLanguageIds = new ArrayList<>(); expectedLanguageIds.add(LANG_ID); @@ -431,6 +411,7 @@ public void testLanguagesDOM() throws Exception { /** * Edge cases for language scope. */ + @Test public void testLanguageScopeDOM() throws Exception { // benchmark entries List entries = new ArrayList<>(); @@ -518,6 +499,7 @@ public void testLanguageScopeDOM() throws Exception { /** * Test serialization of entries when configuration description is null. */ + @Test public void testNullConfigurationDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -549,6 +531,7 @@ public void testNullConfigurationDOM() throws Exception { /** * Test serialization of entries when language is null. */ + @Test public void testNullLanguageDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -580,6 +563,7 @@ public void testNullLanguageDOM() throws Exception { /** * Test serialization of entries when language scope is null. */ + @Test public void testNullLanguageScopeDOM() throws Exception { // define benchmark entries List entriesNullLanguage = new ArrayList<>(); @@ -657,6 +641,7 @@ public void testNullLanguageScopeDOM() throws Exception { /** * Test serialization of entries when resource is null. */ + @Test public void testNullResourceDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -688,6 +673,7 @@ public void testNullResourceDOM() throws Exception { /** * Test serialization of entries when configuration and language are both null. */ + @Test public void testNullConfigurationLanguageDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -720,6 +706,7 @@ public void testNullConfigurationLanguageDOM() throws Exception { /** * Test serialization of entries when configuration and resource are both null. */ + @Test public void testNullConfigurationResourceDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -752,6 +739,7 @@ public void testNullConfigurationResourceDOM() throws Exception { /** * Test serialization of entries when language and resource are both null. */ + @Test public void testNullLanguageResourceDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -784,6 +772,7 @@ public void testNullLanguageResourceDOM() throws Exception { /** * Test serialization of entries when configuration, language and resource are all null. */ + @Test public void testNullConfigurationLanguageResourceFlagDOM() throws Exception { // provider/configuration/language/resource/settingEntry Element elementProvider; @@ -819,6 +808,7 @@ public void testNullConfigurationLanguageResourceFlagDOM() throws Exception { /** * Serialization of include path. */ + @Test public void testCIncludePathEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -854,6 +844,7 @@ public void testCIncludePathEntryDOM() throws Exception { /** * Serialization of include file. */ + @Test public void testCIncludeFileEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -888,6 +879,7 @@ public void testCIncludeFileEntryDOM() throws Exception { /** * Serialization of macro. */ + @Test public void testCMacroEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -922,6 +914,7 @@ public void testCMacroEntryDOM() throws Exception { /** * Serialization of macro file. */ + @Test public void testCMacroFileEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -956,6 +949,7 @@ public void testCMacroFileEntryDOM() throws Exception { /** * Serialization of library path. */ + @Test public void testCLibraryPathEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -990,6 +984,7 @@ public void testCLibraryPathEntryDOM() throws Exception { /** * Serialization of library file. */ + @Test public void testCLibraryFileEntryDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -1024,6 +1019,7 @@ public void testCLibraryFileEntryDOM() throws Exception { /** * Serialization of entries of different types. */ + @Test public void testMixedSettingEntriesDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -1056,6 +1052,7 @@ public void testMixedSettingEntriesDOM() throws Exception { /** * Serialization of include path. */ + @Test public void testEntryFlagsDOM() throws Exception { Element elementProvider; List entries = new ArrayList<>(); @@ -1094,6 +1091,7 @@ public void testEntryFlagsDOM() throws Exception { /** * Serialization of entries for default and specific languages together. */ + @Test public void testLanguageAndNullDOM() throws Exception { Element elementProvider = null; @@ -1132,6 +1130,7 @@ public void testLanguageAndNullDOM() throws Exception { /** * Serialization of entries for 2 languages. */ + @Test public void testTwoLanguagesDOM() throws Exception { Element elementProvider = null; @@ -1172,6 +1171,7 @@ public void testTwoLanguagesDOM() throws Exception { /** * Serialization of entries for different resources. */ + @Test public void testTwoResourcesDOM() throws Exception { // Create resources IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); @@ -1220,6 +1220,7 @@ public void testTwoResourcesDOM() throws Exception { /** * Serialization of entries for resource hierarchy. */ + @Test public void testParentFolder() throws Exception { // Create model project and accompanied descriptions IProject project = ResourceHelper.createCDTProjectWithConfig(this.getName()); @@ -1238,7 +1239,7 @@ public void testParentFolder() throws Exception { List entries = new ArrayList<>(); entries.add(new CIncludePathEntry("path0", 0)); provider.setSettingEntries(null, parentFolder, LANG_ID, entries); - provider.setSettingEntries(null, emptySettingsPath, LANG_ID, new ArrayList()); + provider.setSettingEntries(null, emptySettingsPath, LANG_ID, new ArrayList<>()); { // retrieve entries for a parent folder itself @@ -1274,6 +1275,7 @@ public void testParentFolder() throws Exception { /** * Test equals() and hashCode(). */ + @Test public void testEquals() throws Exception { // create sample entries List sampleEntries_1 = new ArrayList<>(); @@ -1399,6 +1401,7 @@ public void testEquals() throws Exception { /** * Test equality for properties. */ + @Test public void testEquals_DefaultProperties() throws Exception { // create model providers LanguageSettingsSerializableProvider provider1 = new LanguageSettingsSerializableProvider(PROVIDER_1, @@ -1448,6 +1451,7 @@ public void testEquals_DefaultProperties() throws Exception { /** * Test cloning of provider. */ + @Test public void testClone() throws Exception { // define sample data List sampleEntries_1 = new ArrayList<>(); @@ -1518,6 +1522,7 @@ public MockSerializableProvider clone() throws CloneNotSupportedException { /** * Test shallow clone. */ + @Test public void testCloneShallow() throws Exception { // define sample data List sampleLanguages = new ArrayList<>(); @@ -1562,6 +1567,7 @@ public MockSerializableProvider cloneShallow() throws CloneNotSupportedException /** * Verify that entries are sorted by kinds. */ + @Test public void testSort_Kinds() throws Exception { // create sample entries CIncludePathEntry includePathEntry1 = new CIncludePathEntry("path1", 0); @@ -1619,6 +1625,7 @@ public void testSort_Kinds() throws Exception { /** * Check how entries are sorted inside a kind. */ + @Test public void testSort_Entries() throws Exception { // create sample entries CIncludePathEntry includePathEntry1 = new CIncludePathEntry("path_B", 0); @@ -1678,6 +1685,7 @@ public void testSort_Entries() throws Exception { /** * Sorting including undefined entries. */ + @Test public void testSort_Undef() throws Exception { // create sample entries CMacroEntry macroEntry1 = new CMacroEntry("MACRO_1", null, 0); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java index dd1b093405f..81aa08fc93c 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ASTCacheTests.java @@ -14,6 +14,13 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; @@ -23,7 +30,7 @@ import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.model.ASTCache; import org.eclipse.cdt.internal.core.model.ASTCache.ASTRunnable; @@ -35,14 +42,14 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for the {@link ASTCache}. */ -public class ASTCacheTests extends BaseTestCase { +public class ASTCacheTests extends BaseTestCase5 { private final static boolean DEBUG = false; private static int fgReconcilerCount; @@ -93,21 +100,11 @@ public void run() { private ITranslationUnit fTU2; private IIndex fIndex; - public ASTCacheTests(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite(ASTCacheTests.class); - return suite; - } - private final String SOURCE1 = "void foo1() {}"; //$NON-NLS-1$ private final String SOURCE2 = "void foo2() {}"; //$NON-NLS-1$ - @Override - public void setUp() throws Exception { - super.setUp(); + @BeforeEach + public void prepareTest() throws Exception { IProgressMonitor npm = new NullProgressMonitor(); fProject = createProject("ASTCacheTest"); assertNotNull(fProject); @@ -124,8 +121,8 @@ public void setUp() throws Exception { fIndex.acquireReadLock(); } - @Override - public void tearDown() throws Exception { + @AfterEach + public void deleteProject() throws Exception { if (fIndex != null) { fIndex.releaseReadLock(); } @@ -143,6 +140,7 @@ protected IFile createFile(IContainer container, String fileName, String content return TestSourceReader.createFile(container, new Path(fileName), contents); } + @Test public void testASTCache() throws Exception { checkActiveElement(); checkSingleThreadAccess(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java index 541c4ad696e..b045b21369f 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ArchiveTests.java @@ -14,6 +14,9 @@ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -32,8 +35,10 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; import junit.framework.TestSuite; /** @@ -43,7 +48,8 @@ * class. There is nothing exotic here, mostly just sanity type tests * */ -public class ArchiveTests extends TestCase { +public class ArchiveTests { + IWorkspace workspace; IWorkspaceRoot root; ICProject testProject; @@ -51,12 +57,8 @@ public class ArchiveTests extends TestCase { Path cpath, exepath, libpath, archpath, objpath; NullProgressMonitor monitor; - /** - * Constructor for ArchiveTests - * @param name - */ - public ArchiveTests(String name) { - super(name); + @BeforeEach + protected void setUp() throws Exception { /*** * The assume that they have a working workspace * and workspace root object to use to create projects/files in, @@ -70,19 +72,6 @@ public ArchiveTests(String name) { if (root == null) fail("Workspace root was not setup"); - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override - protected void setUp() throws Exception { - /*** * Setup the various files, paths and projects that are needed by the * tests @@ -139,7 +128,7 @@ protected void setUp() throws Exception { * * Called after every test case method. */ - @Override + @AfterEach protected void tearDown() { CProjectHelper.delete(testProject); } @@ -152,6 +141,7 @@ public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } + @Test public void testGetBinaries() throws CoreException, FileNotFoundException { IArchive myArchive; IBinary[] bins; @@ -194,11 +184,11 @@ public void testGetBinaries() throws CoreException, FileNotFoundException { } } - assertTrue(expBin.getMissingString(), expBin.gotAll()); - assertTrue(expBin.getExtraString(), !expBin.gotExtra()); + assertTrue(expBin.gotAll(), expBin.getMissingString()); + assertTrue(!expBin.gotExtra(), expBin.getExtraString()); for (x = 0; x < expObj.length; x++) { - assertTrue("Binary " + expBin.expStrings[x] + " " + expObj[x].getMissingString(), expObj[x].gotAll()); - assertTrue("Binary " + expBin.expStrings[x] + " " + expObj[x].getExtraString(), !expObj[x].gotExtra()); + assertTrue(expObj[x].gotAll(), "Binary " + expBin.expStrings[x] + " " + expObj[x].getMissingString()); + assertTrue(!expObj[x].gotExtra(), "Binary " + expBin.expStrings[x] + " " + expObj[x].getExtraString()); } } @@ -206,11 +196,12 @@ public void testGetBinaries() throws CoreException, FileNotFoundException { * Simple sanity test to make sure Archive.isArchive returns true * */ + @Test public void testIsArchive() throws CoreException, FileNotFoundException { IArchive myArchive; myArchive = CProjectHelper.findArchive(testProject, "libtestlib_g.a"); - assertTrue("A archive", myArchive != null); + assertTrue(myArchive != null, "A archive"); myArchive = null; } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java index f05935b0c33..786e2201b67 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/AsmModelBuilderTest.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.IAsmLabel; import org.eclipse.cdt.core.model.ICElement; @@ -24,31 +29,22 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -import junit.framework.Test; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * Tests for the default assembly model builder. * * @since 5.0 */ -public class AsmModelBuilderTest extends BaseTestCase { - - public static Test suite() { - return suite(AsmModelBuilderTest.class, "_"); - } +public class AsmModelBuilderTest extends BaseTestCase5 { private ICProject fCProject; private ITranslationUnit fTU; - public AsmModelBuilderTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void createProject() throws Exception { fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER); assertNotNull(fCProject); CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/asmTests"); @@ -56,10 +52,9 @@ protected void setUp() throws Exception { assertNotNull(fTU); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { CProjectHelper.delete(fCProject); - super.tearDown(); } public void testAsmModelElements() throws Exception { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java index c1d5c0e7f22..482bfb9b870 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/BinaryTests.java @@ -14,6 +14,10 @@ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -36,9 +40,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Peter Graves @@ -47,7 +51,7 @@ * class. There is nothing exotic here, mostly just sanity type tests * */ -public class BinaryTests extends TestCase { +public class BinaryTests { IWorkspace workspace; IWorkspaceRoot root; ICProject testProject; @@ -55,24 +59,7 @@ public class BinaryTests extends TestCase { Path cpath, exepath, libpath, archpath, objpath; NullProgressMonitor monitor; - /** - * Constructor for BinaryTests - * @param name - */ - public BinaryTests(String name) { - super(name); - - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override + @BeforeEach protected void setUp() throws Exception { /*** * The tests assume that they have a working workspace @@ -175,24 +162,17 @@ protected void setUp() throws Exception { * * Called after every test case method. */ - @Override + @AfterEach protected void tearDown() throws CoreException, InterruptedException { System.gc(); System.runFinalization(); CProjectHelper.delete(testProject); } - public static TestSuite suite() { - return new TestSuite(BinaryTests.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - /**** * Simple tests to make sure we can get all of a binarys children */ + @Test public void testGetChildren() throws CoreException, FileNotFoundException { IBinary myBinary; ICElement[] elements; @@ -213,32 +193,34 @@ public void testGetChildren() throws CoreException, FileNotFoundException { expSyms.foundString(elements[i].getElementName()); } - assertTrue(expSyms.getMissingString(), expSyms.gotAll()); + assertTrue(expSyms.gotAll(), expSyms.getMissingString()); // assertTrue(expSyms.getExtraString(), !expSyms.gotExtra()); } /*** * A quick check to make sure the getBSS function works as expected. */ + @Test public void testGetBss() throws CModelException { IBinary bigBinary, littleBinary; bigBinary = CProjectHelper.findBinary(testProject, "exebig_g"); littleBinary = CProjectHelper.findBinary(testProject, "test_g"); - assertTrue("Expected 432, Got: " + bigBinary.getBSS(), bigBinary.getBSS() == 432); - assertTrue("Expected 4, Got: " + littleBinary.getBSS(), littleBinary.getBSS() == 4); + assertTrue(bigBinary.getBSS() == 432, "Expected 432, Got: " + bigBinary.getBSS()); + assertTrue(littleBinary.getBSS() == 4, "Expected 4, Got: " + littleBinary.getBSS()); } /*** * A quick check to make sure the getBSS function works as expected. */ + @Test public void testGetData() throws CModelException { IBinary bigBinary, littleBinary; bigBinary = CProjectHelper.findBinary(testProject, "exebig_g"); littleBinary = CProjectHelper.findBinary(testProject, "test_g"); /* These two test used to fail due to pr 23602 */ - assertTrue("Expected 256 Got: " + bigBinary.getData(), bigBinary.getData() == 256); - assertTrue("Expected 196, Got: " + littleBinary.getData(), littleBinary.getData() == 196); + assertTrue(bigBinary.getData() == 256, "Expected 256 Got: " + bigBinary.getData()); + assertTrue(littleBinary.getData() == 196, "Expected 196, Got: " + littleBinary.getData()); } /*** @@ -246,19 +228,21 @@ public void testGetData() throws CModelException { * something sane for the most common exe type (x86) and one other (ppc) * This is not a in depth test at all. */ + @Test public void testGetCpu() throws CModelException { IBinary myBinary; myBinary = CProjectHelper.findBinary(testProject, "exebig_g"); - assertTrue("Expected: x86 Got: " + myBinary.getCPU(), myBinary.getCPU().equals("x86")); + assertTrue(myBinary.getCPU().equals("x86"), "Expected: x86 Got: " + myBinary.getCPU()); myBinary = CProjectHelper.findBinary(testProject, ppcexefile.getLocation().lastSegment()); - assertTrue("Expected: ppc Got: " + myBinary.getCPU(), myBinary.getCPU().equals("ppc")); + assertTrue(myBinary.getCPU().equals("ppc"), "Expected: ppc Got: " + myBinary.getCPU()); } /**** * A set of simple tests to make sute getNeededSharedLibs seems to be sane */ + @Test public void testGetNeededSharedLibs() throws CModelException { IBinary myBinary; String[] exelibs = { "libsocket.so.2", "libc.so.2" }; @@ -273,8 +257,8 @@ public void testGetNeededSharedLibs() throws CModelException { for (x = 0; x < gotlibs.length; x++) { exp.foundString(gotlibs[x]); } - assertTrue(exp.getMissingString(), exp.gotAll()); - assertTrue(exp.getExtraString(), !exp.gotExtra()); + assertTrue(exp.gotAll(), exp.getMissingString()); + assertTrue(!exp.gotExtra(), exp.getExtraString()); exp = new ExpectedStrings(bigexelibs); myBinary = CProjectHelper.findBinary(testProject, "exebig_g"); @@ -282,8 +266,8 @@ public void testGetNeededSharedLibs() throws CModelException { for (x = 0; x < gotlibs.length; x++) { exp.foundString(gotlibs[x]); } - assertTrue(exp.getMissingString(), exp.gotAll()); - assertTrue(exp.getExtraString(), !exp.gotExtra()); + assertTrue(exp.gotAll(), exp.getMissingString()); + assertTrue(!exp.gotExtra(), exp.getExtraString()); exp = new ExpectedStrings(bigexelibs); myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so"); @@ -291,14 +275,15 @@ public void testGetNeededSharedLibs() throws CModelException { for (x = 0; x < gotlibs.length; x++) { exp.foundString(gotlibs[x]); } - assertTrue(exp.getMissingString(), exp.gotAll()); - assertTrue(exp.getExtraString(), !exp.gotExtra()); + assertTrue(exp.gotAll(), exp.getMissingString()); + assertTrue(!exp.gotExtra(), exp.getExtraString()); } /**** * Simple tests for the getSoname method; */ + @Test public void testGetSoname() throws CModelException { IBinary myBinary; String name; @@ -308,25 +293,27 @@ public void testGetSoname() throws CModelException { myBinary = CProjectHelper.findBinary(testProject, "libtestlib_g.so"); name = myBinary.getSoname(); assertNotNull(name); - assertTrue("Expected: libtestlib_g.so.1 Got: " + name, name.equals("libtestlib_g.so.1")); + assertTrue(name.equals("libtestlib_g.so.1"), "Expected: libtestlib_g.so.1 Got: " + name); } /*** * Simple tests for getText */ + @Test public void testGetText() throws CModelException { IBinary bigBinary, littleBinary; bigBinary = CProjectHelper.findBinary(testProject, bigexe.getLocation().lastSegment()); littleBinary = CProjectHelper.findBinary(testProject, exefile.getLocation().lastSegment()); /* These two asserts used to fail due to pr 23602 */ - assertTrue("Expected 886, Got: " + bigBinary.getText(), bigBinary.getText() == 886); - assertTrue("Expected 1223, Got: " + littleBinary.getText(), littleBinary.getText() == 1223); + assertTrue(bigBinary.getText() == 886, "Expected 886, Got: " + bigBinary.getText()); + assertTrue(littleBinary.getText() == 1223, "Expected 1223, Got: " + littleBinary.getText()); } /*** * Simple tests for the hadDebug call */ + @Test public void testHasDebug() throws CModelException { IBinary myBinary; myBinary = CProjectHelper.findBinary(testProject, "test_g"); @@ -340,6 +327,7 @@ public void testHasDebug() throws CModelException { /*** * Sanity - isBinary and isReadonly should always return true; */ + @Test public void testisBinRead() throws CModelException { IBinary myBinary; myBinary = CProjectHelper.findBinary(testProject, "test_g"); @@ -351,6 +339,7 @@ public void testisBinRead() throws CModelException { /*** * Quick tests to make sure isObject works as expected. */ + @Test public void testIsObject() throws CModelException { IBinary myBinary; myBinary = CProjectHelper.findObject(testProject, "exetest.o"); @@ -370,6 +359,7 @@ public void testIsObject() throws CModelException { /*** * Quick tests to make sure isSharedLib works as expected. */ + @Test public void testIsSharedLib() throws CModelException { IBinary myBinary; @@ -390,6 +380,7 @@ public void testIsSharedLib() throws CModelException { /*** * Quick tests to make sure isExecutable works as expected. */ + @Test public void testIsExecutable() throws InterruptedException, CModelException { IBinary myBinary; myBinary = CProjectHelper.findObject(testProject, "exetest.o"); @@ -410,11 +401,12 @@ public void testIsExecutable() throws InterruptedException, CModelException { * Simple sanity test to make sure Binary.isBinary returns true * */ + @Test public void testIsBinary() throws CoreException, FileNotFoundException, Exception { IBinary myBinary; myBinary = CProjectHelper.findBinary(testProject, "exebig_g"); - assertTrue("A Binary", myBinary != null); + assertTrue(myBinary != null, "A Binary"); } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java index e696740ec97..6cf0204f980 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/Bug311189Tests.java @@ -14,13 +14,15 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Arrays; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.resources.IPathEntryStore; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.cdt.internal.core.model.SourceEntry; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -30,8 +32,8 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.Job; - -import junit.framework.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Regression test for Bug 311189. @@ -39,16 +41,12 @@ * we must ensure that we don't corrupt the set of includes in the incoming * project's metadata */ -public class Bug311189Tests extends BaseTestCase { - - public static Test suite() { - return suite(Bug311189Tests.class, "_"); - } +public class Bug311189Tests extends BaseTestCase5 { private IProject project; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { project = ResourceHelper.createCDTProjectWithConfig("bug311189"); } @@ -56,6 +54,7 @@ protected void setUp() throws Exception { * If a source folder is deleted and re-created in a separate Job, ensure that we don't * delete the source folder from the C Model. */ + @Test public void testPathSettingLost() throws Exception { IFolder srcFolder = project.getFolder("src"); final IPathEntry sourceEntry = new SourceEntry(srcFolder.getFullPath(), new IPath[0]); @@ -64,7 +63,7 @@ public void testPathSettingLost() throws Exception { srcFolder.create(true, true, null); CoreModel.setRawPathEntries(CoreModel.getDefault().create(project), new IPathEntry[] { sourceEntry }, null); IPathEntry[] rawEntries = CoreModel.getPathEntryStore(project).getRawPathEntries(); - assertTrue("Path entry unset!", Arrays.asList(rawEntries).contains(sourceEntry)); + assertTrue(Arrays.asList(rawEntries).contains(sourceEntry), "Path entry unset!"); try { // None-batched resource change, though we do hold a scheduling rule @@ -88,7 +87,7 @@ public void run(IProgressMonitor monitor) throws CoreException { IPathEntryStore store = CoreModel.getPathEntryStore(project); rawEntries = store.getRawPathEntries(); - assertTrue("Path entry gone!", Arrays.asList(rawEntries).contains(sourceEntry)); + assertTrue(Arrays.asList(rawEntries).contains(sourceEntry), "Path entry gone!"); } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java index 7bd09401790..7442dee498d 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderBugsTest.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; @@ -22,29 +25,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -import junit.framework.Test; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for C model builder bugs. */ -public class CModelBuilderBugsTest extends BaseTestCase { - - public static Test suite() { - return suite(CModelBuilderBugsTest.class, "_"); - } +public class CModelBuilderBugsTest extends BaseTestCase5 { private ICProject fCProject; private ITranslationUnit fTU; - public CModelBuilderBugsTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void createProject() throws Exception { fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER); assertNotNull(fCProject); CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/cmodel"); @@ -52,12 +47,12 @@ protected void setUp() throws Exception { assertNotNull(fTU); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { CProjectHelper.delete(fCProject); - super.tearDown(); } + @Test public void testModelBuilderBug222398() throws Exception { IStructure clazz = (IStructure) fTU.getElement("Test"); assertNotNull(clazz); @@ -73,11 +68,13 @@ public void testModelBuilderBug222398() throws Exception { assertEquals("decl", functions[1].getElementName()); } + @Test public void testModelBuilderBug262785() throws Exception { assertNotNull(fTU.getElement("Unknown1::method")); assertNotNull(fTU.getElement("Unknown2::method")); } + @Test public void testModelBuilderBug274490() throws Exception { IStructure clazz = (IStructure) fTU.getElement("Bug274490"); assertNotNull(clazz); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java index 303e04bc78b..0d9d1a9003c 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelBuilderInactiveCodeTest.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IInclude; @@ -21,29 +25,21 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - -import junit.framework.Test; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for C model inactive code parsing. */ -public class CModelBuilderInactiveCodeTest extends BaseTestCase { - - public static Test suite() { - return suite(CModelBuilderInactiveCodeTest.class, "_"); - } +public class CModelBuilderInactiveCodeTest extends BaseTestCase5 { private ICProject fCProject; private ITranslationUnit fTU; - public CModelBuilderInactiveCodeTest(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); + @BeforeEach + protected void createProject() throws Exception { fCProject = CProjectHelper.createCProject(getName(), null, IPDOMManager.ID_FAST_INDEXER); assertNotNull(fCProject); CProjectHelper.importSourcesFromPlugin(fCProject, CTestPlugin.getDefault().getBundle(), "/resources/cmodel"); @@ -51,12 +47,12 @@ protected void setUp() throws Exception { assertNotNull(fTU); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { CProjectHelper.delete(fCProject); - super.tearDown(); } + @Test public void testPreprocessorNodes() throws Exception { ISourceReference e = (ISourceReference) fTU.getElement("include"); assertTrue(e instanceof IInclude); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java index 04772796b82..eebad8e5186 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelElementsTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.List; @@ -47,33 +51,23 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.Test; -import junit.framework.TestSuite; - -public class CModelElementsTests extends BaseTestCase { +public class CModelElementsTests extends BaseTestCase5 { private ICProject fCProject; private IFile headerFile; private IFile includedFile; private NullProgressMonitor monitor; - public static Test suite() { - TestSuite suite = new TestSuite(CModelElementsTests.class.getName()); - suite.addTest(new CModelElementsTests("testCModelElements")); - return suite; - } - - public CModelElementsTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { monitor = new NullProgressMonitor(); fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); headerFile = fCProject.getProject().getFile("CModelElementsTest.h"); @@ -96,11 +90,12 @@ protected void setUp() throws Exception { waitForIndexer(fCProject); } - @Override - protected void tearDown() { + @AfterEach + protected void deleteProject() { CProjectHelper.delete(fCProject); } + @Test public void testCModelElements() throws CModelException { ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile); //ITranslationUnit included = (ITranslationUnit)CoreModel.getDefault().create(includedFile); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java index fb6573d788e..2d3f9f46de7 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelExceptionTest.java @@ -14,13 +14,14 @@ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICModelStatusConstants; import org.eclipse.cdt.internal.core.model.CModelStatus; import org.eclipse.core.runtime.CoreException; - -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * CModelExceptionTest @@ -28,78 +29,48 @@ * @author Judy N. Green * @since Jul 19, 2002 */ -public class CModelExceptionTest extends TestCase { +public class CModelExceptionTest { // Shared values setup and torn down private CModelStatus cModelStatus; private CoreException coreException; - /** - * Constructor for TestCModelException. - * @param name - */ - public CModelExceptionTest(String name) { - super(name); - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override + @BeforeEach protected void setUp() { // create shared resources and setup the test fixture cModelStatus = new CModelStatus(); coreException = new CoreException(cModelStatus); } - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - @Override - protected void tearDown() { - // release resources here and clean-up - } - - public static TestSuite suite() { - return new TestSuite(CModelExceptionTest.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - + @Test public void testCreationNoStatus() { CModelException testException = new CModelException(coreException); // should be the same object inside - assertTrue("Object compare failed", testException.getException() == coreException); + assertTrue(testException.getException() == coreException, "Object compare failed"); } + @Test public void testCreationWithStatus() { CModelException testException = new CModelException(coreException, ICModelStatusConstants.INDEX_OUT_OF_BOUNDS); // should not be null - assertTrue("TestException.getStatus() is null", (testException.getStatus() != null)); + assertTrue((testException.getStatus() != null), "TestException.getStatus() is null"); // should have the same status as was set on creation - assertTrue("Object compare failed", - testException.getStatus().getCode() == ICModelStatusConstants.INDEX_OUT_OF_BOUNDS); + assertTrue(testException.getStatus().getCode() == ICModelStatusConstants.INDEX_OUT_OF_BOUNDS, + "Object compare failed"); } + @Test public void testElementDoesNotExist() { CModelException testException = new CModelException(coreException, ICModelStatusConstants.ELEMENT_DOES_NOT_EXIST); // should not exist since this is the value we set on creation - assertTrue("Object unexpectedly exists", testException.doesNotExist()); + assertTrue(testException.doesNotExist(), "Object unexpectedly exists"); } + @Test public void testElementExists() { CModelException testException = new CModelException(coreException, ICModelStatusConstants.INVALID_CONTENTS); // should not exist since this is the value we set on creation - assertTrue("Object unexpectedly does not exist", !testException.doesNotExist()); + assertTrue(!testException.doesNotExist(), "Object unexpectedly does not exist"); } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java index 24f39c0dbba..90b9860f754 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelIdentifierTests.java @@ -14,6 +14,9 @@ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.ArrayList; @@ -27,13 +30,14 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Tests for CModel identifier API. @@ -43,17 +47,13 @@ * * @since 5.0 */ -public class CModelIdentifierTests extends BaseTestCase { - - public static Test suite() { - return BaseTestCase.suite(CModelIdentifierTests.class); - } +public class CModelIdentifierTests extends BaseTestCase5 { private ICProject fCProject; private IFile fHeaderFile; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { // reusing project setup from CModelElementsTests NullProgressMonitor monitor = new NullProgressMonitor(); fCProject = CProjectHelper.createCCProject("CModelIdentifierTests", "bin", IPDOMManager.ID_FAST_INDEXER); @@ -72,11 +72,12 @@ protected void setUp() throws Exception { waitForIndexer(fCProject); } - @Override - protected void tearDown() { + @AfterEach + protected void deleteProject() { CProjectHelper.delete(fCProject); } + @Test public void testIdentifierConsistency() throws Exception { ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(fHeaderFile); @@ -109,9 +110,9 @@ public boolean visit(ICElement element) throws CoreException { for (int i = 0; i < size; i++) { ICElement expected = (ICElement) elements.get(i); String identifier = (String) identifiers.get(i); - assertNotNull("Could not create identifier for element: " + expected, identifier); + assertNotNull(identifier, "Could not create identifier for element: " + expected); ICElement actual = CoreModel.create(identifier); - assertNotNull("Cannot create element '" + expected + "' from identifier: " + identifier, actual); + assertNotNull(actual, "Cannot create element '" + expected + "' from identifier: " + identifier); assertEquals(expected.getElementName(), actual.getElementName()); assertEquals(expected.getElementType(), actual.getElementType()); assertEquals(expected, actual); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java index debd3248780..fa5cbc0a506 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CModelTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; @@ -61,38 +66,23 @@ import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider; import org.eclipse.ui.wizards.datatransfer.ImportOperation; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; -import junit.framework.TestCase; -import junit.framework.TestSuite; - /** * This file contains a set of generic tests for the core C model. Nothing * exotic, but should be a small sanity set of tests. */ -public class CModelTests extends TestCase { +public class CModelTests { + IWorkspace workspace; IWorkspaceRoot root; IProject project_c, project_cc; NullProgressMonitor monitor; - /** - * Constructor for CModelTests. - * @param name - */ - public CModelTests(String name) { - super(name); - } - - /** - * Sets up the test fixture. - * - * Called before every test case method. - * - * Example code test the packages in the project - * "com.qnx.tools.ide.cdt.core" - */ - @Override + @BeforeEach protected void setUp() throws Exception { /*** * The test of the tests assume that they have a working workspace @@ -118,19 +108,11 @@ protected void setUp() throws Exception { * * Called after every test case method. */ - @Override + @AfterEach protected void tearDown() throws CoreException { BaseTestCase5.assertWorkspaceIsEmpty(); } - public static TestSuite suite() { - return new TestSuite(CModelTests.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - /*** * The follow are a simple set of tests to make usre the HasC/CCNature calls * seem to be sane. @@ -142,21 +124,22 @@ public static void main(String[] args) { * @see CProjectHelper#createCProject * @see CoreModel#addCCNature */ + @Test public void testHasNature() throws CoreException { ICProject testProject; testProject = CProjectHelper.createCProject("naturetest", "none", IPDOMManager.ID_NO_INDEXER); if (testProject == null) fail("Unable to create project"); - assertTrue("hasCNature works", CoreModel.hasCNature(testProject.getProject())); - assertTrue("hasCCNature works without ccnature", !(CoreModel.hasCCNature(testProject.getProject()))); + assertTrue(CoreModel.hasCNature(testProject.getProject()), "hasCNature works"); + assertTrue(!(CoreModel.hasCCNature(testProject.getProject())), "hasCCNature works without ccnature"); CCProjectNature.addCCNature(testProject.getProject(), monitor); - assertTrue("hasCCNature works", (CoreModel.hasCCNature(testProject.getProject()))); + assertTrue((CoreModel.hasCCNature(testProject.getProject())), "hasCCNature works"); CCProjectNature.removeCCNature(testProject.getProject(), monitor); CProjectNature.removeCNature(testProject.getProject(), monitor); - assertTrue("hasCNature works without cnature", !CoreModel.hasCNature(testProject.getProject())); - assertTrue("hasCCNature works without ccnature or cnature", !(CoreModel.hasCCNature(testProject.getProject()))); + assertTrue(!CoreModel.hasCNature(testProject.getProject()), "hasCNature works without cnature"); + assertTrue(!(CoreModel.hasCCNature(testProject.getProject())), "hasCCNature works without ccnature or cnature"); try { testProject.getProject().delete(true, true, monitor); } catch (CoreException e) { @@ -167,6 +150,7 @@ public void testHasNature() throws CoreException { * Simple tests to make sure the models file identification methods seem * to work as expected. */ + @Test public void testFileType() throws CoreException, FileNotFoundException { ICProject testProject; testProject = CProjectHelper.createCProject("filetest", "none", IPDOMManager.ID_NO_INDEXER); @@ -183,12 +167,12 @@ public void testFileType() throws CoreException, FileNotFoundException { /*** * file should be a binary, executable, not shared or archive */ - assertTrue("isBinary", CoreModel.getDefault().isBinary(file)); - assertTrue("isExecutable", CoreModel.getDefault().isExecutable(file)); - assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file)); - assertTrue("isArchive", !CoreModel.getDefault().isArchive(file)); - assertTrue("isObject", !CoreModel.getDefault().isObject(file)); - assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file)); + assertTrue(CoreModel.getDefault().isBinary(file), "isBinary"); + assertTrue(CoreModel.getDefault().isExecutable(file), "isExecutable"); + assertTrue(!CoreModel.getDefault().isSharedLib(file), "isSharedLib"); + assertTrue(!CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(!CoreModel.getDefault().isObject(file), "isObject"); + assertTrue(!CoreModel.isTranslationUnit(file), "isTranslationUnit"); file = testProject.getProject().getFile("exetest.c"); if (!file.exists()) { @@ -198,12 +182,12 @@ public void testFileType() throws CoreException, FileNotFoundException { /*** * file should be a translation unit */ - assertTrue("isBinary", !CoreModel.getDefault().isBinary(file)); - assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file)); - assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file)); - assertTrue("isArchive", !CoreModel.getDefault().isArchive(file)); - assertTrue("isObject", !CoreModel.getDefault().isObject(file)); - assertTrue("isTranslationUnit", CoreModel.isTranslationUnit(file)); + assertTrue(!CoreModel.getDefault().isBinary(file), "isBinary"); + assertTrue(!CoreModel.getDefault().isExecutable(file), "isExecutable"); + assertTrue(!CoreModel.getDefault().isSharedLib(file), "isSharedLib"); + assertTrue(!CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(!CoreModel.getDefault().isObject(file), "isObject"); + assertTrue(CoreModel.isTranslationUnit(file), "isTranslationUnit"); file = testProject.getProject().getFile("exetest.o"); if (!file.exists()) { @@ -215,12 +199,12 @@ public void testFileType() throws CoreException, FileNotFoundException { /*** * file should be a object file unit */ - assertTrue("isBinary", CoreModel.getDefault().isBinary(file)); - assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file)); - assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file)); - assertTrue("isArchive", !CoreModel.getDefault().isArchive(file)); - assertTrue("isObject", CoreModel.getDefault().isObject(file)); - assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file)); + assertTrue(CoreModel.getDefault().isBinary(file), "isBinary"); + assertTrue(!CoreModel.getDefault().isExecutable(file), "isExecutable"); + assertTrue(!CoreModel.getDefault().isSharedLib(file), "isSharedLib"); + assertTrue(!CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(CoreModel.getDefault().isObject(file), "isObject"); + assertTrue(!CoreModel.isTranslationUnit(file), "isTranslationUnit"); file = testProject.getProject().getFile("liblibtest_g.so"); if (!file.exists()) { @@ -231,12 +215,12 @@ public void testFileType() throws CoreException, FileNotFoundException { /*** * file should be a sharedlib/binary file */ - assertTrue("isBinary", CoreModel.getDefault().isBinary(file)); - assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file)); - assertTrue("isSharedLib", CoreModel.getDefault().isSharedLib(file)); - assertTrue("isArchive", !CoreModel.getDefault().isArchive(file)); - assertTrue("isObject", !CoreModel.getDefault().isObject(file)); - assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file)); + assertTrue(CoreModel.getDefault().isBinary(file), "isBinary"); + assertTrue(!CoreModel.getDefault().isExecutable(file), "isExecutable"); + assertTrue(CoreModel.getDefault().isSharedLib(file), "isSharedLib"); + assertTrue(!CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(!CoreModel.getDefault().isObject(file), "isObject"); + assertTrue(!CoreModel.isTranslationUnit(file), "isTranslationUnit"); file = testProject.getProject().getFile("liblibtest_g.a"); if (!file.exists()) { @@ -249,13 +233,13 @@ public void testFileType() throws CoreException, FileNotFoundException { /*** * file should be a archive file */ - assertTrue("isArchive", CoreModel.getDefault().isArchive(file)); - assertTrue("isBinary:", !CoreModel.getDefault().isBinary(file)); - assertTrue("isExecutable", !CoreModel.getDefault().isExecutable(file)); - assertTrue("isSharedLib", !CoreModel.getDefault().isSharedLib(file)); - assertTrue("isArchive", CoreModel.getDefault().isArchive(file)); - assertTrue("isObject", !CoreModel.getDefault().isObject(file)); - assertTrue("isTranslationUnit", !CoreModel.isTranslationUnit(file)); + assertTrue(CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(!CoreModel.getDefault().isBinary(file), "isBinary:"); + assertTrue(!CoreModel.getDefault().isExecutable(file), "isExecutable"); + assertTrue(!CoreModel.getDefault().isSharedLib(file), "isSharedLib"); + assertTrue(CoreModel.getDefault().isArchive(file), "isArchive"); + assertTrue(!CoreModel.getDefault().isObject(file), "isObject"); + assertTrue(!CoreModel.isTranslationUnit(file), "isTranslationUnit"); try { testProject.getProject().delete(true, true, monitor); @@ -266,13 +250,15 @@ public void testFileType() throws CoreException, FileNotFoundException { /**** * Some simple tests for isValidTranslationUnitName */ + @Test public void testIsValidTranslationUnitName() throws CoreException { - assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "notcfile")); - assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.c.file")); - assertTrue("Invalid C file", !CoreModel.isValidTranslationUnitName(null, "not.ca")); - assertTrue("Valid C file", CoreModel.isValidTranslationUnitName(null, "areal.c")); + assertTrue(!CoreModel.isValidTranslationUnitName(null, "notcfile"), "Invalid C file"); + assertTrue(!CoreModel.isValidTranslationUnitName(null, "not.c.file"), "Invalid C file"); + assertTrue(!CoreModel.isValidTranslationUnitName(null, "not.ca"), "Invalid C file"); + assertTrue(CoreModel.isValidTranslationUnitName(null, "areal.c"), "Valid C file"); } + @Test public void testCElementVisitorLeave() throws Exception { ICProject testProject = null; try { @@ -324,6 +310,7 @@ public void leave(ICElement element) throws CoreException { } // bug 275609 + @Test public void testSourceExclusionFilters_275609() throws Exception { ICProject testProject = null; try { @@ -345,27 +332,27 @@ public void testSourceExclusionFilters_275609() throws Exception { file2.create(new ByteArrayInputStream(new byte[0]), true, monitor); List cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); + assertEquals((long) 1, (long) cSourceRoots.size()); assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); List cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); cContainers.removeIf(element -> ".settings".equals(element.getElementName())); - assertEquals(1, cContainers.size()); + assertEquals((long) 1, (long) cContainers.size()); assertEquals("test", cContainers.get(0).getElementName()); ICContainer testContainer = (ICContainer) cContainers.get(0); List subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(2, subContainers.size()); + assertEquals((long) 2, (long) subContainers.size()); assertEquals("1", subContainers.get(0).getElementName()); assertEquals("2", subContainers.get(1).getElementName()); Object[] nonCResources = testContainer.getNonCResources(); - assertEquals(0, nonCResources.length); + assertEquals((long) 0, (long) nonCResources.length); List tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); + assertEquals((long) 1, (long) tUnits.size()); assertEquals("test0.c", tUnits.get(0).getElementName()); ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); @@ -384,25 +371,25 @@ public void testSourceExclusionFilters_275609() throws Exception { CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); + assertEquals((long) 1, (long) cSourceRoots.size()); assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); sourceRoot = (ISourceRoot) cSourceRoots.get(0); cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); cContainers.removeIf(element -> ".settings".equals(element.getElementName())); - assertEquals(1, cContainers.size()); + assertEquals((long) 1, (long) cContainers.size()); assertEquals("test", cContainers.get(0).getElementName()); testContainer = (ICContainer) cContainers.get(0); tUnits = testContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); + assertEquals((long) 0, (long) tUnits.size()); subContainers = testContainer.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(0, subContainers.size()); + assertEquals((long) 0, (long) subContainers.size()); nonCResources = testContainer.getNonCResources(); - assertEquals(3, nonCResources.length); + assertEquals((long) 3, (long) nonCResources.length); assertEquals(subFolder1, nonCResources[0]); assertEquals(subFolder2, nonCResources[1]); assertEquals(file0, nonCResources[2]); @@ -418,6 +405,7 @@ public void testSourceExclusionFilters_275609() throws Exception { } // bug 179474 + @Test public void testSourceExclusionFilters_179474() throws Exception { ICProject testProject = null; try { @@ -433,24 +421,24 @@ public void testSourceExclusionFilters_179474() throws Exception { fileB.create(new ByteArrayInputStream(new byte[0]), true, monitor); List cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); + assertEquals((long) 1, (long) cSourceRoots.size()); assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); ISourceRoot sourceRoot = (ISourceRoot) cSourceRoots.get(0); List cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); cContainers.removeIf(element -> ".settings".equals(element.getElementName())); - assertEquals(1, cContainers.size()); + assertEquals((long) 1, (long) cContainers.size()); assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); ICContainer subContainer = (ICContainer) cContainers.get(0); List tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); + assertEquals((long) 1, (long) tUnits.size()); assertEquals(fileB.getName(), tUnits.get(0).getElementName()); tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); - assertEquals(1, tUnits.size()); + assertEquals((long) 1, (long) tUnits.size()); assertEquals(fileA.getName(), tUnits.get(0).getElementName()); ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); @@ -469,26 +457,26 @@ public void testSourceExclusionFilters_179474() throws Exception { CoreModel.getDefault().setProjectDescription(testProject.getProject(), prjDesc); cSourceRoots = testProject.getChildrenOfType(ICElement.C_CCONTAINER); - assertEquals(1, cSourceRoots.size()); + assertEquals((long) 1, (long) cSourceRoots.size()); assertEquals(testProject.getElementName(), cSourceRoots.get(0).getElementName()); sourceRoot = (ISourceRoot) cSourceRoots.get(0); cContainers = sourceRoot.getChildrenOfType(ICElement.C_CCONTAINER); cContainers.removeIf(element -> ".settings".equals(element.getElementName())); - assertEquals(1, cContainers.size()); + assertEquals((long) 1, (long) cContainers.size()); assertEquals(subFolder.getName(), cContainers.get(0).getElementName()); subContainer = (ICContainer) cContainers.get(0); tUnits = subContainer.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); + assertEquals((long) 0, (long) tUnits.size()); tUnits = sourceRoot.getChildrenOfType(ICElement.C_UNIT); - assertEquals(0, tUnits.size()); + assertEquals((long) 0, (long) tUnits.size()); Object[] nonCResources = subContainer.getNonCResources(); - assertEquals(1, nonCResources.length); + assertEquals((long) 1, (long) nonCResources.length); assertEquals(fileB, nonCResources[0]); nonCResources = sourceRoot.getNonCResources(); @@ -504,6 +492,7 @@ public void testSourceExclusionFilters_179474() throws Exception { } // bug 294965 + @Test public void testBinaryInProjectRoot_294965() throws Exception { ICProject testProject; testProject = CProjectHelper.createCProject("bug294965", "none", IPDOMManager.ID_NO_INDEXER); @@ -545,7 +534,7 @@ public void testBinaryInProjectRoot_294965() throws Exception { assertEquals(outputEntry, cfg.getBuildSetting().getOutputDirectories()[0]); Object[] nonCResources = testProject.getNonCResources(); - assertEquals(7, nonCResources.length); + assertEquals((long) 7, (long) nonCResources.length); try { testProject.getProject().delete(true, true, monitor); @@ -554,6 +543,7 @@ public void testBinaryInProjectRoot_294965() throws Exception { } // bug 131165 + @Test public void testPickUpBinariesInNewFolder_131165() throws Exception { ICProject testProject; testProject = CProjectHelper.createCProject("bug131165", "none", IPDOMManager.ID_NO_INDEXER); @@ -563,7 +553,7 @@ public void testPickUpBinariesInNewFolder_131165() throws Exception { CProjectHelper.addDefaultBinaryParser(testProject.getProject()); final IBinaryContainer bin = testProject.getBinaryContainer(); - assertEquals(0, bin.getBinaries().length); + assertEquals((long) 0, (long) bin.getBinaries().length); final boolean binContainerChanged[] = { false }; @@ -614,7 +604,7 @@ public void run() { waiter.join(1000); assertTrue(binContainerChanged[0]); - assertEquals(2, bin.getBinaries().length); + assertEquals((long) 2, (long) bin.getBinaries().length); try { testProject.getProject().delete(true, true, monitor); @@ -640,6 +630,7 @@ public String queryOverwrite(String file) { } } + @Test public void testBinaryContainerDeltaAfterCloseProjDeleteBin_349564() throws Exception { ICProject testProject; testProject = CProjectHelper.createCProject("bug349564", "none", IPDOMManager.ID_NO_INDEXER); @@ -649,10 +640,10 @@ public void testBinaryContainerDeltaAfterCloseProjDeleteBin_349564() throws Exce CProjectHelper.addDefaultBinaryParser(testProject.getProject()); final IBinaryContainer bin = testProject.getBinaryContainer(); - assertEquals(0, bin.getBinaries().length); + assertEquals((long) 0, (long) bin.getBinaries().length); // import with folder structure importSourcesFromPlugin(testProject, CTestPlugin.getDefault().getBundle(), "resources/exe/x86/o"); - assertEquals(1, bin.getBinaries().length); + assertEquals((long) 1, (long) bin.getBinaries().length); IResource resource = bin.getBinaries()[0].getResource(); final boolean binContainerChanged[] = { false }; @@ -707,7 +698,7 @@ public void run() { // wait for delta notification waiter.join(1000); - assertEquals(0, testProject.getBinaryContainer().getBinaries().length); + assertEquals((long) 0, (long) testProject.getBinaryContainer().getBinaries().length); assertTrue(binContainerChanged[0]); try { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java index 119986250a0..b89f1fc3bdb 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/CPathEntryTest.java @@ -33,18 +33,20 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSourceEntry; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /* * CPathEntryTest */ -public class CPathEntryTest extends BaseTestCase { +public class CPathEntryTest extends BaseTestCase5 { private ICProject testProject; @@ -82,26 +84,17 @@ public void elementChanged(ElementChangedEvent event) { } - /** - * Constructor for CModelTests. - * - * @param name - */ - public CPathEntryTest(String name) { - super(name); - } - /** * Sets up the test fixture. * * Called before every test case method. * */ - @Override - protected void setUp() throws CoreException { + @BeforeEach + protected void createProject() throws CoreException { testProject = CProjectHelper.createCProject("cpathtest", "none", IPDOMManager.ID_NO_INDEXER); if (testProject == null) { - fail("Unable to create project"); + Assertions.fail("Unable to create project"); } } @@ -110,26 +103,23 @@ protected void setUp() throws CoreException { * * Called after every test case method. */ - @Override - protected void tearDown() throws CoreException { + @AfterEach + protected void deleteProject() throws CoreException { testProject.getProject().delete(true, null); } - public static TestSuite suite() { - return suite(CPathEntryTest.class); - } - /******************************************************************************************************************************* * Check if the PathEntry's are generated. * * @see CProjectHelper#createCProject */ + @Test public void testCPathEntries() throws CoreException { IPathEntry[] entries = testProject.getResolvedPathEntries(); // We always have at least two entries: // 1) the default sourceEntry becomes the project // 2) the default outputEntry becomes the project - assertTrue("No cpathentries", entries.length == 2); + Assertions.assertTrue(entries.length == 2, "No cpathentries"); entries = new IPathEntry[3]; entries[0] = CoreModel.newIncludeEntry(new Path(""), null, new Path("/usr/include"), true); entries[1] = CoreModel.newIncludeEntry(new Path("cpaththest/foo.c"), null, new Path("/usr/include"), true); @@ -140,7 +130,7 @@ public void testCPathEntries() throws CoreException { // We always have at least two entries: // 1) the default sourceEntry becomes the project // 2) the default outputEntry becomes the project - assertTrue("Expecting 5 pathentries", entries.length == (3 + 2)); + Assertions.assertTrue(entries.length == (3 + 2), "Expecting 5 pathentries"); testProject.setRawPathEntries(null, null); } @@ -149,6 +139,7 @@ public void testCPathEntries() throws CoreException { * * @see CProjectHelper#createCProject */ + @Test public void testCPathEntriesDelta() throws CoreException { CProjectHelper.addCContainer(testProject, "foo"); IPathEntry[] entries = new IPathEntry[3]; @@ -162,12 +153,13 @@ public void testCPathEntriesDelta() throws CoreException { entries = testProject.getResolvedPathEntries(); //CoreModel.getDefault().removeElementChangedListener(listener); testProject.setRawPathEntries(null, null); - assertTrue("Expecting 3 pathEntries deltas", listener.count > 1); + Assertions.assertTrue(listener.count > 1, "Expecting 3 pathEntries deltas"); } /** * Check the IPathEntryContainer. */ + @Test public void testPathEntryContainer() throws CoreException { final IPath containerID = new Path("Testing/Container"); IContainerEntry containerEntry = CoreModel.newContainerEntry(containerID); @@ -200,15 +192,16 @@ public IPath getPath() { // We always have at least two entries: // 1) the default sourceEntry becomes the project // 2) the default outputEntry becomes the project - assertTrue("Expecting 3 pathentries from container", entries.length == (3 + 2)); + Assertions.assertTrue(entries.length == (3 + 2), "Expecting 3 pathentries from container"); } + @Test public void testSetExclusionFilter_Bug197486() throws Exception { // get project description ICProjectDescription prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), true); ICConfigurationDescription activeCfg = prjDesc.getActiveConfiguration(); - assertNotNull(activeCfg); + Assertions.assertNotNull(activeCfg); // add filter to source entry ICSourceEntry[] entries = activeCfg.getSourceEntries(); @@ -227,7 +220,7 @@ public void testSetExclusionFilter_Bug197486() throws Exception { // check again. prjDesc = CoreModel.getDefault().getProjectDescription(testProject.getProject(), false); ICConfigurationDescription[] allConfigs = prjDesc.getConfigurations(); - assertEquals(1, allConfigs.length); + Assertions.assertEquals((long) 1, (long) allConfigs.length); checkExclusionPatterns(sourceEntryName, exclusionPatterns, allConfigs[0]); activeCfg = prjDesc.getActiveConfiguration(); @@ -236,14 +229,14 @@ public void testSetExclusionFilter_Bug197486() throws Exception { private void checkExclusionPatterns(String sourceEntryName, IPath[] exclusionPatterns, ICConfigurationDescription cfg) { - assertNotNull(cfg); + Assertions.assertNotNull(cfg); ICSourceEntry[] entries = cfg.getSourceEntries(); - assertEquals(1, entries.length); - assertEquals(sourceEntryName, entries[0].getName()); + Assertions.assertEquals((long) 1, (long) entries.length); + Assertions.assertEquals(sourceEntryName, entries[0].getName()); IPath[] actualExclusionPatterns = entries[0].getExclusionPatterns(); - assertEquals(exclusionPatterns.length, actualExclusionPatterns.length); - assertEquals(toSet(exclusionPatterns), toSet(actualExclusionPatterns)); + Assertions.assertEquals((long) exclusionPatterns.length, (long) actualExclusionPatterns.length); + Assertions.assertEquals(toSet(exclusionPatterns), toSet(actualExclusionPatterns)); } private Set toSet(Object[] array) { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java index 62f7a2da250..a797bd7b842 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/DeclaratorsTests.java @@ -17,6 +17,9 @@ */ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IFunction; @@ -24,21 +27,13 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITypeDef; import org.eclipse.cdt.core.model.IVariable; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author bnicolle * */ public class DeclaratorsTests extends IntegratedCModelTest { - /** - * @param name - */ - public DeclaratorsTests(String name) { - super(name); - } /** * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest @@ -56,15 +51,7 @@ public String getSourcefileResource() { return "DeclaratorsTests.cpp"; } - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(DeclaratorsTests.class); - return suite; - } - + @Test public void testDeclarators_0001() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0001"); @@ -75,6 +62,7 @@ public void testDeclarators_0001() throws CModelException { assertEquals(decl.getReturnType(), "void"); } + @Test public void testDeclarators_0002() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0002"); @@ -85,6 +73,7 @@ public void testDeclarators_0002() throws CModelException { assertEquals(decl.getReturnType(), "void"); } + @Test public void testDeclarators_0003() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0003"); @@ -95,6 +84,7 @@ public void testDeclarators_0003() throws CModelException { assertEquals(decl.getReturnType(), "void"); } + @Test public void testDeclarators_0004() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0004"); @@ -105,6 +95,7 @@ public void testDeclarators_0004() throws CModelException { assertEquals(decl.getReturnType(), "void*"); } + @Test public void testDeclarators_0005() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0005"); @@ -114,6 +105,7 @@ public void testDeclarators_0005() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0006() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0006"); @@ -123,6 +115,7 @@ public void testDeclarators_0006() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0007() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0007"); @@ -132,6 +125,7 @@ public void testDeclarators_0007() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0011() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0011"); @@ -141,6 +135,7 @@ public void testDeclarators_0011() throws CModelException { assertEquals(decl.getTypeName(), "void(char)"); } + @Test public void testDeclarators_0012() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0012"); @@ -150,6 +145,7 @@ public void testDeclarators_0012() throws CModelException { assertEquals(decl.getTypeName(), "void(char)"); } + @Test public void testDeclarators_0013() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0013"); @@ -159,6 +155,7 @@ public void testDeclarators_0013() throws CModelException { assertEquals(decl.getTypeName(), "void(char)"); } + @Test public void testDeclarators_0014() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0014"); @@ -168,6 +165,7 @@ public void testDeclarators_0014() throws CModelException { assertEquals(decl.getTypeName(), "void*(char)"); } + @Test public void testDeclarators_0015() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0015"); @@ -177,6 +175,7 @@ public void testDeclarators_0015() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0016() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0016"); @@ -186,6 +185,7 @@ public void testDeclarators_0016() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0017() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0017"); @@ -195,6 +195,7 @@ public void testDeclarators_0017() throws CModelException { assertEquals(decl.getTypeName(), "void(*)(char)"); } + @Test public void testDeclarators_0023() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0023"); @@ -205,6 +206,7 @@ public void testDeclarators_0023() throws CModelException { assertEquals(decl.getReturnType(), "void(**)(char)"); } + @Test public void testDeclarators_0024() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0024"); @@ -214,6 +216,7 @@ public void testDeclarators_0024() throws CModelException { assertEquals(decl.getTypeName(), "void(*(*(*)(int))(float))(char)"); } + @Test public void testDeclarators_0031() throws CModelException { ITranslationUnit tu = getTU(); ICElement element = tu.getElement("decl_0031"); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java index 3812ad83034..ceeb8a58eaa 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ElementDeltaTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.Iterator; @@ -31,21 +36,19 @@ import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.TestPluginLauncher; import org.eclipse.cdt.internal.core.model.CModelManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Class for testing the C Element Delta Builder. */ -public class ElementDeltaTests extends TestCase implements IElementChangedListener { +public class ElementDeltaTests implements IElementChangedListener { private ICProject fCProject; private IFile headerFile; private NullProgressMonitor monitor; @@ -53,21 +56,7 @@ public class ElementDeltaTests extends TestCase implements IElementChangedListen private Vector removedElements; private Vector changedElements; - public static void main(String[] args) { - TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), WorkingCopyTests.class, args); - } - - public static Test suite() { - TestSuite suite = new TestSuite(ElementDeltaTests.class.getName()); - suite.addTest(new ElementDeltaTests("testElementDeltas")); - return suite; - } - - public ElementDeltaTests(String name) { - super(name); - } - - @Override + @BeforeEach protected void setUp() throws Exception { monitor = new NullProgressMonitor(); @@ -93,11 +82,12 @@ protected void setUp() throws Exception { changedElements = new Vector(20); } - @Override + @AfterEach protected void tearDown() { CProjectHelper.delete(fCProject); } + @Test public void testElementDeltas() throws Exception { //ITranslationUnit tu = new TranslationUnit(fCProject, headerFile); ICElement celement = CoreModel.getDefault().create(headerFile); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java index f24e6ac03d2..c598a2b9a17 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/FlagTests.java @@ -13,11 +13,12 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.model.Flags; import org.eclipse.cdt.internal.core.model.IConstants; - -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * @author Peter Graves @@ -26,18 +27,10 @@ * there are no very silly problems in the class. It also verifies that there * is no overlap in the IConstants. */ -public class FlagTests extends TestCase { +public class FlagTests { int flags[]; - /** - * Constructor for FlagTests. - * @param name - */ - public FlagTests(String name) { - super(name); - } - /** * Sets up the test fixture. * @@ -46,7 +39,7 @@ public FlagTests(String name) { * Example code test the packages in the project * "com.qnx.tools.ide.cdt.core" */ - @Override + @BeforeEach protected void setUp() { flags = new int[15]; flags[0] = IConstants.AccPublic; @@ -67,138 +60,133 @@ protected void setUp() { } - /** - * Tears down the test fixture. - * - * Called after every test case method. - */ - @Override - protected void tearDown() { - // release resources here and clean-up - } - - public static TestSuite suite() { - return new TestSuite(FlagTests.class); - } - - public static void main(String[] args) { - junit.textui.TestRunner.run(suite()); - } - + @Test public void testIsStatic() { int x; - assertTrue("isStatic with a static", Flags.isStatic(IConstants.AccStatic)); + assertTrue(Flags.isStatic(IConstants.AccStatic), "isStatic with a static"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccStatic) - assertTrue("isStatic with a non-static", !Flags.isStatic(flags[x])); + assertTrue(!Flags.isStatic(flags[x]), "isStatic with a non-static"); } } + @Test public void testIsAbstract() { int x; - assertTrue("isAbstract with a abstract", Flags.isAbstract(IConstants.AccAbstract)); + assertTrue(Flags.isAbstract(IConstants.AccAbstract), "isAbstract with a abstract"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccAbstract) - assertTrue("isAbstract with a non-abstract", !Flags.isAbstract(flags[x])); + assertTrue(!Flags.isAbstract(flags[x]), "isAbstract with a non-abstract"); } } + @Test public void testIsExplicit() { int x; - assertTrue("isExplicit with a explicit", Flags.isExplicit(IConstants.AccExplicit)); + assertTrue(Flags.isExplicit(IConstants.AccExplicit), "isExplicit with a explicit"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccExplicit) - assertTrue("isExplicit with a non-explicit", !Flags.isExplicit(flags[x])); + assertTrue(!Flags.isExplicit(flags[x]), "isExplicit with a non-explicit"); } } + @Test public void testIsExport() { int x; - assertTrue("isExport with a Export", Flags.isExport(IConstants.AccExport)); + assertTrue(Flags.isExport(IConstants.AccExport), "isExport with a Export"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccExport) - assertTrue("isExport with a non-Export", !Flags.isExport(flags[x])); + assertTrue(!Flags.isExport(flags[x]), "isExport with a non-Export"); } } + @Test public void testIsExtern() { int x; - assertTrue("isExtern with a Extern", Flags.isExtern(IConstants.AccExtern)); + assertTrue(Flags.isExtern(IConstants.AccExtern), "isExtern with a Extern"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccExtern) - assertTrue("isExtern with a non-Extern", !Flags.isExtern(flags[x])); + assertTrue(!Flags.isExtern(flags[x]), "isExtern with a non-Extern"); } } + @Test public void testIsInline() { int x; - assertTrue("isInline with a Inline", Flags.isInline(IConstants.AccInline)); + assertTrue(Flags.isInline(IConstants.AccInline), "isInline with a Inline"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccInline) - assertTrue("isInline with a non-Inline", !Flags.isInline(flags[x])); + assertTrue(!Flags.isInline(flags[x]), "isInline with a non-Inline"); } } + @Test public void testIsMutable() { int x; - assertTrue("isMutable with a Mutable", Flags.isMutable(IConstants.AccMutable)); + assertTrue(Flags.isMutable(IConstants.AccMutable), "isMutable with a Mutable"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccMutable) - assertTrue("isMutable with a non-Mutable", !Flags.isMutable(flags[x])); + assertTrue(!Flags.isMutable(flags[x]), "isMutable with a non-Mutable"); } } + @Test public void testIsPrivate() { int x; - assertTrue("isPrivate with a Private", Flags.isPrivate(IConstants.AccPrivate)); + assertTrue(Flags.isPrivate(IConstants.AccPrivate), "isPrivate with a Private"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccPrivate) - assertTrue("isPrivate with a non-Private", !Flags.isPrivate(flags[x])); + assertTrue(!Flags.isPrivate(flags[x]), "isPrivate with a non-Private"); } } + @Test public void testIsPublic() { int x; - assertTrue("isPublic with a Public", Flags.isPublic(IConstants.AccPublic)); + assertTrue(Flags.isPublic(IConstants.AccPublic), "isPublic with a Public"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccPublic) - assertTrue("isPublic with a non-Public", !Flags.isPublic(flags[x])); + assertTrue(!Flags.isPublic(flags[x]), "isPublic with a non-Public"); } } + @Test public void testIsProtected() { int x; - assertTrue("isProtected with a Protected", Flags.isProtected(IConstants.AccProtected)); + assertTrue(Flags.isProtected(IConstants.AccProtected), "isProtected with a Protected"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccProtected) - assertTrue("isProtected with a non-Protected", !Flags.isProtected(flags[x])); + assertTrue(!Flags.isProtected(flags[x]), "isProtected with a non-Protected"); } } + @Test public void testIsRegister() { int x; - assertTrue("isRegister with a Register", Flags.isRegister(IConstants.AccRegister)); + assertTrue(Flags.isRegister(IConstants.AccRegister), "isRegister with a Register"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccRegister) - assertTrue("isRegister with a non-Register", !Flags.isRegister(flags[x])); + assertTrue(!Flags.isRegister(flags[x]), "isRegister with a non-Register"); } } + @Test public void testIsVirtual() { int x; - assertTrue("isVirtual with a Virtual", Flags.isVirtual(IConstants.AccVirtual)); + assertTrue(Flags.isVirtual(IConstants.AccVirtual), "isVirtual with a Virtual"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccVirtual) - assertTrue("isVirtual with a non-Virtual", !Flags.isVirtual(flags[x])); + assertTrue(!Flags.isVirtual(flags[x]), "isVirtual with a non-Virtual"); } } + @Test public void testIsVolatile() { int x; - assertTrue("isVolatile with a Volatile", Flags.isVolatile(IConstants.AccVolatile)); + assertTrue(Flags.isVolatile(IConstants.AccVolatile), "isVolatile with a Volatile"); for (x = 0; x < flags.length; x++) { if (flags[x] != IConstants.AccVolatile) - assertTrue("isVolatile with a non-Volatile", !Flags.isVolatile(flags[x])); + assertTrue(!Flags.isVolatile(flags[x]), "isVolatile with a non-Volatile"); } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java index cb510076b93..325970cfb06 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IIncludeTests.java @@ -18,14 +18,14 @@ */ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.LinkedHashMap; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IInclude; import org.eclipse.cdt.core.model.ITranslationUnit; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author bnicolle @@ -33,13 +33,6 @@ */ public class IIncludeTests extends IntegratedCModelTest { - /** - * @param string - */ - public IIncludeTests(String string) { - super(string); - } - /** * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest */ @@ -56,23 +49,11 @@ public String getSourcefileResource() { return "IIncludeTest.h"; } - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(IIncludeTests.class); - return suite; - } - + @Test public void testGetIncludeName() throws CModelException { ITranslationUnit tu = getTU(); IInclude[] theIncludes = null; - try { - theIncludes = tu.getIncludes(); - } catch (CModelException c) { - assertNotNull("CModelException thrown", c); - } + theIncludes = tu.getIncludes(); LinkedHashMap expectIncludes = new LinkedHashMap(); expectIncludes.put("stdio.h", Boolean.TRUE); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java index a2d3f3cc554..e27ea3253e0 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IMacroTests.java @@ -17,15 +17,16 @@ */ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.List; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IMacro; import org.eclipse.cdt.core.model.ITranslationUnit; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; /** * IMacroTest - Class for testing IMacro @@ -34,25 +35,6 @@ * */ public class IMacroTests extends IntegratedCModelTest { - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(IMacroTests.class.getName()); - suite.addTest(new IMacroTests("testGetElementName")); - // TODO Bug# 38740: suite.addTest( new IMacroTest("testGetIdentifierList")); - // TODO Bug# 38740: suite.addTest( new IMacroTest("testGetTokenSequence")); - return suite; - } - - /** - * @param name - */ - public IMacroTests(String name) { - super(name); - } - /** * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest */ @@ -69,6 +51,7 @@ public String getSourcefileResource() { return "IMacroTest.h"; } + @Test public void testGetElementName() throws CModelException { ITranslationUnit tu = getTU(); List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO); @@ -81,6 +64,8 @@ public void testGetElementName() throws CModelException { } } + @Test + @Disabled("TODO Bug# 38740") public void testGetIdentifierList() throws CModelException { ITranslationUnit tu = getTU(); List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO); @@ -93,6 +78,8 @@ public void testGetIdentifierList() throws CModelException { } } + @Test + @Disabled("TODO Bug# 38740") public void testGetTokenSequence() throws CModelException { ITranslationUnit tu = getTU(); List arrayElements = tu.getChildrenOfType(ICElement.C_MACRO); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java index 9dd04057e7a..b422c779587 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IStructureTests.java @@ -13,6 +13,12 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.List; import org.eclipse.cdt.core.model.CModelException; @@ -22,21 +28,12 @@ import org.eclipse.cdt.core.model.IStructure; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author bnicolle */ public class IStructureTests extends IntegratedCModelTest { - /** - * @param name - */ - public IStructureTests(String name) { - super(name); - } - /** * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest */ @@ -53,38 +50,7 @@ public String getSourcefileResource() { return "IStructure.cpp"; } - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(IStructureTests.class.getName()); - - // TODO check C-only behaviour using C_NATURE vs CC_NATURE - - // Interface tests: - suite.addTest(new IStructureTests("testGetChildrenOfTypeStruct")); - suite.addTest(new IStructureTests("testGetChildrenOfTypeClass")); // C++ only - suite.addTest(new IStructureTests("testGetFields")); - //Bug# 38985: solved. suite.addTest(new IStructureTests("testGetFieldsHack")); - suite.addTest(new IStructureTests("testGetField")); - suite.addTest(new IStructureTests("testGetMethods")); // C++ only - //Bug# 38985: solved. suite.addTest(new IStructureTests("testGetMethodsHack")); // C++ only - suite.addTest(new IStructureTests("testGetMethod")); // C++ only - suite.addTest(new IStructureTests("testIsStruct")); - suite.addTest(new IStructureTests("testIsClass")); // C++ only - suite.addTest(new IStructureTests("testIsUnion")); - suite.addTest(new IStructureTests("testIsAbstract")); // C++ only - suite.addTest(new IStructureTests("testGetBaseTypes")); // C++ only - suite.addTest(new IStructureTests("testGetAccessControl")); // C++ only - - // Language Specification tests: - suite.addTest(new IStructureTests("testAnonymousStructObject")); - suite.addTest(new IStructureTests("testInnerStruct")); - - return suite; - } - + @Test public void testGetChildrenOfTypeStruct() throws CModelException { ITranslationUnit tu = getTU(); List arrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -93,11 +59,12 @@ public void testGetChildrenOfTypeStruct() throws CModelException { assertEquals(myExpectedStructs.length, arrayStructs.size()); for (int i = 0; i < myExpectedStructs.length; i++) { IStructure myIStruct = (IStructure) arrayStructs.get(i); - assertNotNull("Failed on " + i, myIStruct); + assertNotNull(myIStruct, "Failed on " + i); assertEquals(myExpectedStructs[i], myIStruct.getElementName()); } } + @Test public void testGetChildrenOfTypeClass() throws CModelException { ITranslationUnit tu = getTU(); List arrayClasses = tu.getChildrenOfType(ICElement.C_CLASS); @@ -106,11 +73,12 @@ public void testGetChildrenOfTypeClass() throws CModelException { assertEquals(myExpectedClasses.length, arrayClasses.size()); for (int i = 0; i < myExpectedClasses.length; i++) { IStructure myIStruct = (IStructure) arrayClasses.get(i); - assertNotNull("Failed on " + i, myIStruct); + assertNotNull(myIStruct, "Failed on " + i); assertEquals(myExpectedClasses[i], myIStruct.getElementName()); } } + @Test public void testGetFields() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -119,12 +87,13 @@ public void testGetFields() throws CModelException { String[] myExpectedFields = { "m_field1", "m_field2", "m_field3", "m_field4", "m_field5", "m_field6", }; assertEquals(myExpectedFields.length, myArrayIField.length); for (int i = 0; i < myArrayIField.length; i++) { - assertNotNull("Failed on " + i, myArrayIField[i]); - assertEquals("Failed on " + i, myExpectedFields[i], myArrayIField[i].getElementName()); + assertNotNull(myArrayIField[i], "Failed on " + i); + assertEquals(myExpectedFields[i], myArrayIField[i].getElementName(), "Failed on " + i); } } // TODO Bug# 38985: remove testGetFieldsHack() + @Test public void testGetFieldsHack() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -134,11 +103,12 @@ public void testGetFieldsHack() throws CModelException { assertEquals(myExpectedFields.length, myArrayIField.size()); for (int i = 0; i < myArrayIField.size(); i++) { IField myIField = (IField) myArrayIField.get(i); - assertNotNull("Failed on " + i, myIField); - assertEquals("Failed on " + i, myExpectedFields[i], myIField.getElementName()); + assertNotNull(myIField, "Failed on " + i); + assertEquals(myExpectedFields[i], myIField.getElementName(), "Failed on " + i); } } + @Test public void testGetField() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -146,16 +116,17 @@ public void testGetField() throws CModelException { String[] myExpectedFields = { "m_field1", "m_field2", "m_field3", "m_field4", "m_field5", "m_field6", }; for (int i = 0; i < myExpectedFields.length; i++) { IField myIField = myIStruct.getField(myExpectedFields[i]); - assertNotNull("Failed on " + i, myIField); + assertNotNull(myIField, "Failed on " + i); } String[] myUnexpectedFields = { "m_field7", "m_field8", "m_field9", }; for (int i = 0; i < myUnexpectedFields.length; i++) { IField myIField = myIStruct.getField(myUnexpectedFields[i]); - assertNull("Failed on " + i, myIField); + assertNull(myIField, "Failed on " + i); } } + @Test public void testGetMethods() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -164,12 +135,13 @@ public void testGetMethods() throws CModelException { String[] myExpectedMethods = { "method1", "method2", "testStruct1", "~testStruct1" }; assertEquals(myExpectedMethods.length, myArrayIMethod.length); for (int i = 0; i < myArrayIMethod.length; i++) { - assertNotNull("Failed on " + i, myArrayIMethod[i]); - assertEquals("Failed on " + i, myExpectedMethods[i], myArrayIMethod[i].getElementName()); + assertNotNull(myArrayIMethod[i], "Failed on " + i); + assertEquals(myExpectedMethods[i], myArrayIMethod[i].getElementName(), "Failed on " + i); } } // TODO Bug# 38985: remove testGetMethodsHack() + @Test public void testGetMethodsHack() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -180,11 +152,12 @@ public void testGetMethodsHack() throws CModelException { assertEquals(myExpectedMethods.length, myArrayIMethod.size()); for (int i = 0; i < myArrayIMethod.size(); i++) { IMethodDeclaration myIMethod = (IMethodDeclaration) myArrayIMethod.get(i); - assertNotNull("Failed on " + i, myIMethod); - assertEquals("Failed on " + i, myExpectedMethods[i], myIMethod.getElementName()); + assertNotNull(myIMethod, "Failed on " + i); + assertEquals(myExpectedMethods[i], myIMethod.getElementName(), "Failed on " + i); } } + @Test public void testGetMethod() throws CModelException { ITranslationUnit tu = getTU(); List myArrayStructs = tu.getChildrenOfType(ICElement.C_STRUCT); @@ -192,26 +165,25 @@ public void testGetMethod() throws CModelException { String[] myExpectedMethods = { "method1", "method2", "testStruct1", "~testStruct1" }; for (int i = 0; i < myExpectedMethods.length; i++) { IMethodDeclaration myIMethod = myIStruct.getMethod(myExpectedMethods[i]); - assertNotNull("Failed on " + i, myIMethod); + assertNotNull(myIMethod, "Failed on " + i); } String[] myUnexpectedMethods = { "method7", "method8", "method9", }; for (int i = 0; i < myUnexpectedMethods.length; i++) { IMethodDeclaration myIMethod = myIStruct.getMethod(myUnexpectedMethods[i]); - assertNull("Failed on " + i, myIMethod); + assertNull(myIMethod); } } + @Test public void testIsUnion() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementUnion = null; ICElement myElementNonUnion = null; - try { - myElementUnion = tu.getElement("testUnion1"); - myElementNonUnion = tu.getElement("testStruct1"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + myElementUnion = tu.getElement("testUnion1"); + myElementNonUnion = tu.getElement("testStruct1"); + assertNotNull(myElementUnion); assertTrue(myElementUnion.getElementType() == ICElement.C_UNION); IStructure myStructUnion = (IStructure) myElementUnion; @@ -225,16 +197,14 @@ public void testIsUnion() throws CModelException { assertFalse(myStructNonUnion.isUnion()); } + @Test public void testIsStruct() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementStruct = null; ICElement myElementNonStruct = null; - try { - myElementStruct = tu.getElement("testStruct1"); - myElementNonStruct = tu.getElement("testClass1"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + myElementStruct = tu.getElement("testStruct1"); + myElementNonStruct = tu.getElement("testClass1"); + assertNotNull(myElementStruct); assertTrue(myElementStruct.getElementType() == ICElement.C_STRUCT); IStructure myStructStruct = (IStructure) myElementStruct; @@ -248,16 +218,15 @@ public void testIsStruct() throws CModelException { assertFalse(myStructNonStruct.isStruct()); } + @Test public void testIsClass() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementClass = null; ICElement myElementNonClass = null; - try { - myElementClass = tu.getElement("testClass1"); - myElementNonClass = tu.getElement("testStruct1"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + myElementClass = tu.getElement("testClass1"); + myElementNonClass = tu.getElement("testStruct1"); + assertNotNull(myElementClass); assertTrue(myElementClass.getElementType() == ICElement.C_CLASS); IStructure myStructClass = (IStructure) myElementClass; @@ -271,16 +240,15 @@ public void testIsClass() throws CModelException { assertFalse(myStructNonClass.isClass()); } + @Test public void testIsAbstract() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementAbstract = null; ICElement myElementNonAbstract = null; - try { - myElementAbstract = tu.getElement("testClass4Abstract"); - myElementNonAbstract = tu.getElement("testClass1"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + myElementAbstract = tu.getElement("testClass4Abstract"); + myElementNonAbstract = tu.getElement("testClass1"); + assertNotNull(myElementAbstract); assertTrue(myElementAbstract.getElementType() == ICElement.C_CLASS); IStructure myStructAbstract = (IStructure) myElementAbstract; @@ -295,55 +263,53 @@ public void testIsAbstract() throws CModelException { } // IInheritance + @Test public void testGetBaseTypes() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementDerived = null; String[] myBaseTypes = null; - try { - myElementDerived = tu.getElement("testClass5"); // throws - assertNotNull(myElementDerived); - assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS); - IStructure myStructDerived = (IStructure) myElementDerived; - assertNotNull(myStructDerived); - myBaseTypes = myStructDerived.getSuperClassesNames(); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + myElementDerived = tu.getElement("testClass5"); // throws + assertNotNull(myElementDerived); + assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS); + IStructure myStructDerived = (IStructure) myElementDerived; + assertNotNull(myStructDerived); + myBaseTypes = myStructDerived.getSuperClassesNames(); String[] myExpectedBaseTypes = { "testClass1", "testClass3", "testClass4Abstract" }; assertEquals(myExpectedBaseTypes.length, myBaseTypes.length); for (int i = 0; i < myBaseTypes.length; i++) { - assertEquals("Failed on " + i, myExpectedBaseTypes[i], myBaseTypes[i]); + assertEquals(myExpectedBaseTypes[i], myBaseTypes[i]); } } // IInheritance + @Test public void testGetAccessControl() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElementDerived = null; String[] myBaseTypes = null; - try { - myElementDerived = tu.getElement("testClass5"); // throws - assertNotNull(myElementDerived); - assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS); - IStructure myStructDerived = (IStructure) myElementDerived; - assertNotNull(myStructDerived); - myBaseTypes = myStructDerived.getSuperClassesNames(); - - ASTAccessVisibility[] myExpectedAccessControl = { - // TODO #38986: expect appropriate access control tags - ASTAccessVisibility.PUBLIC, ASTAccessVisibility.PROTECTED, ASTAccessVisibility.PRIVATE }; - assertEquals(myExpectedAccessControl.length, myBaseTypes.length); - for (int i = 0; i < myBaseTypes.length; i++) { - ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]); - assertEquals("Failed on " + i, myExpectedAccessControl[i], myAccessControl); - } - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); + + myElementDerived = tu.getElement("testClass5"); // throws + assertNotNull(myElementDerived); + assertTrue(myElementDerived.getElementType() == ICElement.C_CLASS); + IStructure myStructDerived = (IStructure) myElementDerived; + assertNotNull(myStructDerived); + myBaseTypes = myStructDerived.getSuperClassesNames(); + + ASTAccessVisibility[] myExpectedAccessControl = { + // TODO #38986: expect appropriate access control tags + ASTAccessVisibility.PUBLIC, ASTAccessVisibility.PROTECTED, ASTAccessVisibility.PRIVATE }; + assertEquals(myExpectedAccessControl.length, myBaseTypes.length); + for (int i = 0; i < myBaseTypes.length; i++) { + ASTAccessVisibility myAccessControl = myStructDerived.getSuperClassAccess(myBaseTypes[i]); + assertEquals(myExpectedAccessControl[i], myAccessControl, "Failed on " + i); } + } // getStructureInfo + @Test public void testGetStructureInfo() { } @@ -358,26 +324,23 @@ public void testGetStructureInfo() { // Language Specification Tests // + @Test public void testAnonymousStructObject() throws CModelException { ITranslationUnit tu = getTU(); - ICElement myElement = null; - try { - myElement = tu.getElement("testAnonymousStructObject1"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + ICElement myElement = tu.getElement("testAnonymousStructObject1"); + assertNotNull(myElement); assertEquals(ICElement.C_VARIABLE, myElement.getElementType()); } + @Test public void testInnerStruct() throws CModelException { ITranslationUnit tu = getTU(); ICElement myElement = null; - try { - myElement = tu.getElement("testStruct8"); - } catch (CModelException e) { - assertNotNull("CModelException thrown", e); - } + + myElement = tu.getElement("testStruct8"); + assertNotNull(myElement); IStructure myIStruct = (IStructure) myElement; assertNotNull(myIStruct); @@ -387,8 +350,8 @@ public void testInnerStruct() throws CModelException { assertEquals(myExpectedInnerStructs.length, myInnerStructs.size()); for (int i = 0; i < myExpectedInnerStructs.length; i++) { IStructure myInnerStruct = (IStructure) myInnerStructs.get(i); - assertNotNull("Failed on " + i, myInnerStruct); - assertEquals("Failed on " + i, myExpectedInnerStructs[i], myInnerStruct.getElementName()); + assertNotNull(myInnerStruct, "Failed on " + i); + assertEquals(myExpectedInnerStructs[i], myInnerStruct.getElementName(), "Failed on " + i); } } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java index 93ed3441633..07016dba532 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/ITemplateTests.java @@ -18,6 +18,9 @@ */ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.ArrayList; import java.util.List; @@ -27,9 +30,7 @@ import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.IVariable; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Class for testing ITemplate interface @@ -37,12 +38,6 @@ * */ public class ITemplateTests extends IntegratedCModelTest { - /** - * @param name - */ - public ITemplateTests(String name) { - super(name); - } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.tests.IntegratedCModelTest#getSourcefileSubdir() @@ -60,25 +55,6 @@ public String getSourcefileResource() { return "ITemplate.cpp"; } - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(IStructureTests.class.getName()); - - // Interface tests: - suite.addTest(new ITemplateTests("testGetChildrenOfTypeTemplate")); - suite.addTest(new ITemplateTests("testGetNumberOfTemplateParameters")); - suite.addTest(new ITemplateTests("testGetTemplateParameterTypes")); - suite.addTest(new ITemplateTests("testGetTemplateSignature")); - - // Language Specification tests: - // TBD. - - return suite; - } - public List getTemplateMethods(ITranslationUnit tu) throws CModelException { IStructure myElem = null; try { @@ -92,53 +68,54 @@ public List getTemplateMethods(ITranslationUnit tu) throws CModelException { return list; } + @Test public void testGetChildrenOfTypeTemplate() throws CModelException { ITranslationUnit tu = getTU(); { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT); String[] myExpectedValues = { "Map" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS); String[] myExpectedValues = { "nonVector" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION); String[] myExpectedValues = { "ArrayOverlay" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { // Method from the TemplateContainer List arrayElements = getTemplateMethods(tu); String[] myExpectedValues = { "fum", "scrum", }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); // This test is no correct there is no guaranty on the order // for this particular case for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { @@ -149,14 +126,14 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { // "nonVector::first", // "Foo::fum", }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); // This test is no correct there is no guaranty on the order // for this particular case for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } @@ -164,14 +141,14 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { // Check the template method List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_METHOD); String[] myExpectedValues = { "nonVector::first", "Foo::fum", }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); // This test is no correct there is no guaranty on the order // for this particular case for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } @@ -179,14 +156,14 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { // Template function declation List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION); String[] myExpectedValues = { "IsGreaterThan" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); // This test is no correct there is no guaranty on the order // for this particular case for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { @@ -217,15 +194,16 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE); String[] myExpectedValues = { "default_alloc_template::S_start_free" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { IVariable myITemplate = (IVariable) arrayElements.get(i); - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], myITemplate.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], myITemplate.getElementName(), "Failed on " + i); } } } + @Test public void testGetNumberOfTemplateParameters() throws CModelException { ITranslationUnit tu = getTU(); ArrayList arrayElements = new ArrayList(); @@ -239,14 +217,16 @@ public void testGetNumberOfTemplateParameters() throws CModelException { arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_VARIABLE)); int[] myExpectedNumbers = { 3, 1, 3, 1, 1, 1, 1, 1, 2 }; - assertEquals(myExpectedNumbers.length, arrayElements.size()); + assertEquals((long) myExpectedNumbers.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedNumbers.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); - assertEquals("Failed on " + i, myExpectedNumbers[i], myTemplate.getNumberOfTemplateParameters()); + assertNotNull(myTemplate, "Failed on " + i); + assertEquals((long) myExpectedNumbers[i], (long) myTemplate.getNumberOfTemplateParameters(), + "Failed on " + i); } } + @Test public void testGetTemplateParameterTypes() throws CModelException { ITranslationUnit tu = getTU(); ArrayList arrayElements = new ArrayList(); @@ -278,19 +258,20 @@ public void testGetTemplateParameterTypes() throws CModelException { { "X" }, //"default_alloc_template::S_start_free" { "bool", "int" }, }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); + assertNotNull(myTemplate, "Failed on " + i); String[] myExpectedParams = myExpectedValues[i]; String[] myParams = myTemplate.getTemplateParameterTypes(); - assertEquals("Failed on " + i, myExpectedParams.length, myParams.length); + assertEquals((long) myExpectedParams.length, (long) myParams.length, "Failed on " + i); for (int j = 0; j < myExpectedParams.length; j++) { - assertEquals("Failed on " + i + "," + j, myExpectedParams[j], myParams[j]); + assertEquals(myExpectedParams[j], myParams[j], "Failed on " + i + "," + j); } } } + @Test public void testGetTemplateSignature() throws CModelException { ITranslationUnit tu = getTU(); ArrayList arrayElements = new ArrayList(); @@ -311,11 +292,11 @@ public void testGetTemplateSignature() throws CModelException { // TODO: shouldn't signature indicate const function as well? "IsGreaterThan(X, X) : bool", "default_alloc_template::S_start_free : char*", }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); - assertEquals("Failed on " + i, myExpectedValues[i], myTemplate.getTemplateSignature()); + assertNotNull(myTemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], myTemplate.getTemplateSignature(), "Failed on " + i); } } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java index a0bdf30402f..2974429c1d6 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/IntegratedCModelTest.java @@ -24,32 +24,23 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * @author bnicolle */ -public abstract class IntegratedCModelTest extends BaseTestCase { +public abstract class IntegratedCModelTest extends BaseTestCase5 { private ICProject fCProject; private IFile sourceFile; private NullProgressMonitor monitor; private boolean structuralParse = false; - public IntegratedCModelTest() { - super(); - } - - /** - * @param name - */ - public IntegratedCModelTest(String name) { - super(name); - } - /** * @return the subdirectory (from the plugin root) containing the required * test sourcefile (plus a trailing slash) @@ -61,8 +52,8 @@ public IntegratedCModelTest(String name) { */ abstract public String getSourcefileResource(); - @Override - public void setUp() throws Exception { + @BeforeEach + public void createProject() throws Exception { monitor = new NullProgressMonitor(); fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); sourceFile = fCProject.getProject().getFile(getSourcefileResource()); @@ -80,8 +71,8 @@ public void setUp() throws Exception { waitForIndexer(fCProject); } - @Override - protected void tearDown() { + @AfterEach + protected void deleteProject() { CProjectHelper.delete(fCProject); } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java index f50bfd03e08..ffd0c8fd33b 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/MacroTests.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Stack; import org.eclipse.cdt.core.model.CModelException; @@ -24,21 +26,13 @@ import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.DefaultLineTracker; import org.eclipse.jface.text.ILineTracker; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author bnicolle * */ public class MacroTests extends IntegratedCModelTest { - /** - * @param name - */ - public MacroTests(String name) { - super(name); - } /** * @see org.eclipse.cdt.internal.core.model.IntegratedCModelTest @@ -56,15 +50,7 @@ public String getSourcefileResource() { return "MacroTests.cpp"; } - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(MacroTests.class); - return suite; - } - + @Test public void testBug40759() throws CModelException, BadLocationException { /* This is a list of elements in the test .c file. It will be used * in a number of places in the tests @@ -102,11 +88,11 @@ public void testBug40759() throws CModelException, BadLocationException { if (myElement == null) missing.push(expectedStringList[x]); else { - assertTrue("Expected:" + expectedStringList[x] + " Got:" + myElement.getElementName(), - expectedStringList[x].equals(myElement.getElementName())); + assertTrue(expectedStringList[x].equals(myElement.getElementName()), + "Expected:" + expectedStringList[x] + " Got:" + myElement.getElementName()); - assertTrue("Expected type for '" + expectedStringList[x] + "':" + expectedTypes[x] + " Got:" - + myElement.getElementType(), expectedTypes[x] == myElement.getElementType()); + assertTrue(expectedTypes[x] == myElement.getElementType(), "Expected type for '" + expectedStringList[x] + + "':" + expectedTypes[x] + " Got:" + myElement.getElementType()); int offset = -1; int length = -1; @@ -117,13 +103,11 @@ public void testBug40759() throws CModelException, BadLocationException { length = range.getIdLength(); } - assertTrue( - "Expected offset for '" + expectedStringList[x] + "':" + expectedOffsets[x] + " Got:" + offset, - expectedOffsets[x] == offset); + assertTrue(expectedOffsets[x] == offset, + "Expected offset for '" + expectedStringList[x] + "':" + expectedOffsets[x] + " Got:" + offset); - assertTrue( - "Expected length for '" + expectedStringList[x] + "':" + expectedLengths[x] + " Got:" + length, - expectedLengths[x] == length); + assertTrue(expectedLengths[x] == length, + "Expected length for '" + expectedStringList[x] + "':" + expectedLengths[x] + " Got:" + length); } } @@ -131,7 +115,7 @@ public void testBug40759() throws CModelException, BadLocationException { String output = "Could not get elements: "; while (!missing.empty()) output += missing.pop() + " "; - assertTrue(output, false); + assertTrue(false, output); } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java index 74467897eb2..da0f7730d81 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralCModelElementsTests.java @@ -13,6 +13,10 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; import java.util.List; @@ -47,33 +51,23 @@ import org.eclipse.cdt.core.parser.ast.ASTAccessVisibility; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.Test; -import junit.framework.TestSuite; - -public class StructuralCModelElementsTests extends BaseTestCase { +public class StructuralCModelElementsTests extends BaseTestCase5 { private ICProject fCProject; private IFile headerFile; private IFile includedFile; private NullProgressMonitor monitor; - public static Test suite() { - TestSuite suite = new TestSuite(StructuralCModelElementsTests.class.getName()); - suite.addTest(new StructuralCModelElementsTests("testCModelElements")); //$NON-NLS-1$ - return suite; - } - - public StructuralCModelElementsTests(String name) { - super(name); - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { monitor = new NullProgressMonitor(); fCProject = CProjectHelper.createCCProject("TestProject1", "bin", IPDOMManager.ID_FAST_INDEXER); //$NON-NLS-1$ //$NON-NLS-2$ headerFile = fCProject.getProject().getFile("CModelElementsTest.h"); //$NON-NLS-1$ @@ -95,11 +89,12 @@ protected void setUp() throws Exception { waitForIndexer(fCProject); } - @Override - protected void tearDown() { + @AfterEach + protected void deleteProject() { CProjectHelper.delete(fCProject); } + @Test public void testCModelElements() throws CModelException { ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile); // turn on the structural parse mode diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java index 98c5fb67c6e..dc71a1c180e 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralMacroTests.java @@ -19,30 +19,12 @@ */ import org.eclipse.cdt.core.model.CModelException; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; public class StructuralMacroTests extends IMacroTests { - /** - * @returns a test suite named after this class - * containing all its public members named "test*" - */ - public static Test suite() { - TestSuite suite = new TestSuite(StructuralMacroTests.class.getName()); - suite.addTest(new StructuralMacroTests("testGetElementName")); - return suite; - } - - /** - * @param name - */ - public StructuralMacroTests(String name) { - super(name); - } - @Override + @Test public void testGetElementName() throws CModelException { setStructuralParse(true); super.testGetElementName(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java index b48c782732e..a3c789bdd2d 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralStructureTests.java @@ -14,52 +14,19 @@ package org.eclipse.cdt.core.model.tests; import org.eclipse.cdt.core.model.CModelException; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author hamer * */ public class StructuralStructureTests extends IStructureTests { - /** - * @param name - */ - public StructuralStructureTests(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite(StructuralStructureTests.class.getName()); - - // TODO check C-only behaviour using C_NATURE vs CC_NATURE - - // Interface tests: - suite.addTest(new StructuralStructureTests("testGetChildrenOfTypeStruct")); - suite.addTest(new StructuralStructureTests("testGetChildrenOfTypeClass")); // C++ only - suite.addTest(new StructuralStructureTests("testGetFields")); - suite.addTest(new StructuralStructureTests("testGetField")); - suite.addTest(new StructuralStructureTests("testGetMethods")); // C++ only - suite.addTest(new StructuralStructureTests("testGetMethod")); // C++ only - suite.addTest(new StructuralStructureTests("testIsStruct")); - suite.addTest(new StructuralStructureTests("testIsClass")); // C++ only - suite.addTest(new StructuralStructureTests("testIsUnion")); - suite.addTest(new StructuralStructureTests("testIsAbstract")); // C++ only - suite.addTest(new StructuralStructureTests("testGetBaseTypes")); // C++ only - suite.addTest(new StructuralStructureTests("testGetAccessControl")); // C++ only - - // Language Specification tests: - suite.addTest(new StructuralStructureTests("testAnonymousStructObject")); - suite.addTest(new StructuralStructureTests("testInnerStruct")); - - return suite; - } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.tests.IStructureTests#testAnonymousStructObject() */ @Override + @Test public void testAnonymousStructObject() throws CModelException { setStructuralParse(true); super.testAnonymousStructObject(); @@ -69,6 +36,7 @@ public void testAnonymousStructObject() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetAccessControl() */ @Override + @Test public void testGetAccessControl() throws CModelException { setStructuralParse(true); super.testGetAccessControl(); @@ -78,6 +46,7 @@ public void testGetAccessControl() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetBaseTypes() */ @Override + @Test public void testGetBaseTypes() throws CModelException { setStructuralParse(true); super.testGetBaseTypes(); @@ -87,6 +56,7 @@ public void testGetBaseTypes() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetChildrenOfTypeClass() */ @Override + @Test public void testGetChildrenOfTypeClass() throws CModelException { setStructuralParse(true); super.testGetChildrenOfTypeClass(); @@ -96,6 +66,7 @@ public void testGetChildrenOfTypeClass() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetChildrenOfTypeStruct() */ @Override + @Test public void testGetChildrenOfTypeStruct() throws CModelException { setStructuralParse(true); super.testGetChildrenOfTypeStruct(); @@ -105,6 +76,7 @@ public void testGetChildrenOfTypeStruct() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetField() */ @Override + @Test public void testGetField() throws CModelException { setStructuralParse(true); super.testGetField(); @@ -114,6 +86,7 @@ public void testGetField() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetFields() */ @Override + @Test public void testGetFields() throws CModelException { setStructuralParse(true); super.testGetFields(); @@ -123,6 +96,7 @@ public void testGetFields() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetFieldsHack() */ @Override + @Test public void testGetFieldsHack() throws CModelException { setStructuralParse(true); super.testGetFieldsHack(); @@ -132,6 +106,7 @@ public void testGetFieldsHack() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethod() */ @Override + @Test public void testGetMethod() throws CModelException { setStructuralParse(true); super.testGetMethod(); @@ -141,6 +116,7 @@ public void testGetMethod() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethods() */ @Override + @Test public void testGetMethods() throws CModelException { setStructuralParse(true); super.testGetMethods(); @@ -150,6 +126,7 @@ public void testGetMethods() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetMethodsHack() */ @Override + @Test public void testGetMethodsHack() throws CModelException { setStructuralParse(true); super.testGetMethodsHack(); @@ -159,6 +136,7 @@ public void testGetMethodsHack() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testGetStructureInfo() */ @Override + @Test public void testGetStructureInfo() { setStructuralParse(true); super.testGetStructureInfo(); @@ -168,6 +146,7 @@ public void testGetStructureInfo() { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testInnerStruct() */ @Override + @Test public void testInnerStruct() throws CModelException { setStructuralParse(true); super.testInnerStruct(); @@ -177,6 +156,7 @@ public void testInnerStruct() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsAbstract() */ @Override + @Test public void testIsAbstract() throws CModelException { setStructuralParse(true); super.testIsAbstract(); @@ -186,6 +166,7 @@ public void testIsAbstract() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsClass() */ @Override + @Test public void testIsClass() throws CModelException { setStructuralParse(true); super.testIsClass(); @@ -195,6 +176,7 @@ public void testIsClass() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsStruct() */ @Override + @Test public void testIsStruct() throws CModelException { setStructuralParse(true); super.testIsStruct(); @@ -204,6 +186,7 @@ public void testIsStruct() throws CModelException { * @see org.eclipse.cdt.core.model.tests.IStructureTests#testIsUnion() */ @Override + @Test public void testIsUnion() throws CModelException { setStructuralParse(true); super.testIsUnion(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java index 89cad9ae904..0a142172131 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/StructuralTemplateTests.java @@ -13,6 +13,9 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + import java.util.ArrayList; import java.util.List; @@ -20,72 +23,53 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ITemplate; import org.eclipse.cdt.core.model.ITranslationUnit; - -import junit.framework.Test; -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * @author hamer * */ public class StructuralTemplateTests extends ITemplateTests { - /** - * @param name - */ - public StructuralTemplateTests(String name) { - super(name); - } - - public static Test suite() { - TestSuite suite = new TestSuite(StructuralTemplateTests.class.getName()); - - // Interface tests: - suite.addTest(new StructuralTemplateTests("testGetChildrenOfTypeTemplate")); - suite.addTest(new StructuralTemplateTests("testGetNumberOfTemplateParameters")); - suite.addTest(new StructuralTemplateTests("testGetTemplateParameterTypes")); - suite.addTest(new StructuralTemplateTests("testGetTemplateSignature")); - - return suite; - } /* (non-Javadoc) * @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetChildrenOfTypeTemplate() */ @Override + @Test public void testGetChildrenOfTypeTemplate() throws CModelException { setStructuralParse(true); ITranslationUnit tu = getTU(); { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_STRUCT); String[] myExpectedValues = { "Map" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_CLASS); String[] myExpectedValues = { "nonVector" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { List arrayElements = tu.getChildrenOfType(ICElement.C_TEMPLATE_UNION); String[] myExpectedValues = { "ArrayOverlay" }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } { @@ -97,12 +81,12 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION)); arrayElements.addAll(tu.getChildrenOfType(ICElement.C_TEMPLATE_FUNCTION_DECLARATION)); String[] myExpectedValues = { "fum", "scrum", "nonVector::first", "Foo::fum", "IsGreaterThan", }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ICElement celement = (ICElement) arrayElements.get(i); ITemplate myITemplate = (ITemplate) celement; - assertNotNull("Failed on " + i, myITemplate); - assertEquals("Failed on " + i, myExpectedValues[i], celement.getElementName()); + assertNotNull(myITemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], celement.getElementName(), "Failed on " + i); } } } @@ -111,6 +95,7 @@ public void testGetChildrenOfTypeTemplate() throws CModelException { * @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetNumberOfTemplateParameters() */ @Override + @Test public void testGetNumberOfTemplateParameters() throws CModelException { setStructuralParse(true); ITranslationUnit tu = getTU(); @@ -129,11 +114,12 @@ public void testGetNumberOfTemplateParameters() throws CModelException { // 3,1,3,1,1,3 3, 1, 3, 1, 1, 1, 1, 1/*,2*/ }; - assertEquals(myExpectedNumbers.length, arrayElements.size()); + assertEquals((long) myExpectedNumbers.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedNumbers.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); - assertEquals("Failed on " + i, myExpectedNumbers[i], myTemplate.getNumberOfTemplateParameters()); + assertNotNull(myTemplate, "Failed on " + i); + assertEquals((long) myExpectedNumbers[i], (long) myTemplate.getNumberOfTemplateParameters(), + "Failed on " + i); } } @@ -141,6 +127,7 @@ public void testGetNumberOfTemplateParameters() throws CModelException { * @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetTemplateParameterTypes() */ @Override + @Test public void testGetTemplateParameterTypes() throws CModelException { setStructuralParse(true); ITranslationUnit tu = getTU(); @@ -176,15 +163,15 @@ public void testGetTemplateParameterTypes() throws CModelException { //"default_alloc_template::S_start_free" {"bool", "int"},*/ }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); + assertNotNull(myTemplate, "Failed on " + i); String[] myExpectedParams = myExpectedValues[i]; String[] myParams = myTemplate.getTemplateParameterTypes(); - assertEquals("Failed on " + i, myExpectedParams.length, myParams.length); + assertEquals((long) myExpectedParams.length, (long) myParams.length, "Failed on " + i); for (int j = 0; j < myExpectedParams.length; j++) { - assertEquals("Failed on " + i + "," + j, myExpectedParams[j], myParams[j]); + assertEquals(myExpectedParams[j], myParams[j], "Failed on " + i + "," + j); } } } @@ -193,6 +180,7 @@ public void testGetTemplateParameterTypes() throws CModelException { * @see org.eclipse.cdt.core.model.tests.ITemplateTests#testGetTemplateSignature() */ @Override + @Test public void testGetTemplateSignature() throws CModelException { setStructuralParse(true); ITranslationUnit tu = getTU(); @@ -213,11 +201,11 @@ public void testGetTemplateSignature() throws CModelException { "Foo::fum(int) : void", "IsGreaterThan(X, X) : bool", /*"default_alloc_template::S_start_free : char*",*/ }; - assertEquals(myExpectedValues.length, arrayElements.size()); + assertEquals((long) myExpectedValues.length, (long) arrayElements.size()); for (int i = 0; i < myExpectedValues.length; i++) { ITemplate myTemplate = (ITemplate) arrayElements.get(i); - assertNotNull("Failed on " + i, myTemplate); - assertEquals("Failed on " + i, myExpectedValues[i], myTemplate.getTemplateSignature()); + assertNotNull(myTemplate, "Failed on " + i); + assertEquals(myExpectedValues[i], myTemplate.getTemplateSignature(), "Failed on " + i); } } } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java index ccd886b751e..2e143de801a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitBaseTest.java @@ -13,6 +13,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import org.eclipse.cdt.core.dom.IPDOMManager; @@ -27,29 +29,14 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.TestCase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; /** * @author jcamelon * */ -public abstract class TranslationUnitBaseTest extends TestCase { - /** - * - */ - public TranslationUnitBaseTest() { - super(); - // TODO Auto-generated constructor stub - } - - /** - * @param name - */ - public TranslationUnitBaseTest(String name) { - super(name); - // TODO Auto-generated constructor stub - } +public abstract class TranslationUnitBaseTest { protected IWorkspace workspace; protected IWorkspaceRoot root; @@ -74,7 +61,7 @@ public TranslationUnitBaseTest(String name) { * Example code test the packages in the project * "com.qnx.tools.ide.cdt.core" */ - @Override + @BeforeEach protected void setUp() throws Exception { /*** * The rest of the tests assume that they have a working workspace @@ -152,7 +139,7 @@ protected void setUp() throws Exception { * * Called after every test case method. */ - @Override + @AfterEach protected void tearDown() { // release resources here and clean-up try { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java index c7778bdbe29..a8e73c33348 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/TranslationUnitTests.java @@ -23,8 +23,8 @@ import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.util.ExpectedStrings; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; /** * @author Peter Graves @@ -33,6 +33,7 @@ * There is nothing exotic here, mostly just sanity type tests. */ public class TranslationUnitTests extends TranslationUnitBaseTest { + /* * This is a list of elements in the test .c file. It will be used in a * number of places in the tests @@ -40,25 +41,19 @@ public class TranslationUnitTests extends TranslationUnitBaseTest { private static final String[] expectedStringList = { "stdio.h", "unistd.h", "func2p", "globalvar", "myenum", "mystruct_t", "mystruct", "myunion", "mytype", "func1", "func2", "main", "func3" }; - public TranslationUnitTests(String name) { - super(name); - } - - public static TestSuite suite() { - return new TestSuite(TranslationUnitTests.class); - } - /*************************************************************************** * Simple sanity test to make sure TranslationUnit.isTranslationUnit returns true */ + @Test public void testIsTranslationUnit() throws Exception, FileNotFoundException { ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c"); - assertNotNull(tu); + Assertions.assertNotNull(tu); } /*************************************************************************** * Simple sanity tests to make sure TranslationUnit.getChildren seems to basically work. */ + @Test public void testGetChildren() throws Exception { ExpectedStrings expectedString = new ExpectedStrings(expectedStringList); @@ -70,13 +65,14 @@ public void testGetChildren() throws Exception { expectedString.foundString(elements[x].getElementName()); } } - assertTrue("PR:23603 " + expectedString.getMissingString(), expectedString.gotAll()); - assertTrue(expectedString.getExtraString(), !expectedString.gotExtra()); + Assertions.assertTrue(expectedString.gotAll(), "PR:23603 " + expectedString.getMissingString()); + Assertions.assertTrue(!expectedString.gotExtra(), expectedString.getExtraString()); } /*************************************************************************** * Simple sanity tests for the getElement() call */ + @Test public void testGetElement() throws Exception { Deque missing = new ArrayDeque<>(); ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c"); @@ -86,8 +82,8 @@ public void testGetElement() throws Exception { if (myElement == null) { missing.push(expectedStringList[x]); } else { - assertTrue("Expected: \"" + expectedStringList[x] + "\". Got:" + myElement.getElementName(), - expectedStringList[x].equals(myElement.getElementName())); + Assertions.assertTrue(expectedStringList[x].equals(myElement.getElementName()), + "Expected: \"" + expectedStringList[x] + "\". Got:" + myElement.getElementName()); } } if (!missing.isEmpty()) { @@ -95,13 +91,14 @@ public void testGetElement() throws Exception { while (!missing.isEmpty()) { output.append(" ").append(missing.pop()); } - assertTrue(output.toString(), false); + Assertions.assertTrue(false, output.toString()); } } /*************************************************************************** * Simple sanity tests for the getInclude call */ + @Test public void testBug23478A() throws Exception { String includes[] = { "stdio.h", "unistd.h" }; ITranslationUnit tu = CProjectHelper.findTranslationUnit(testProject, "exetest.c"); @@ -109,12 +106,12 @@ public void testBug23478A() throws Exception { for (int x = 0; x < includes.length; x++) { IInclude include = tu.getInclude(includes[x]); if (include == null) { - fail("Unable to get include: " + includes[x]); + Assertions.fail("Unable to get include: " + includes[x]); } else { // Failed test: Include.getIncludeName() always returns ""; // assertTrue - assertTrue("PR:23478 Expected: an empty string. Got: " + include.getIncludeName(), - includes[x].equals(include.getIncludeName())); + Assertions.assertTrue(includes[x].equals(include.getIncludeName()), + "PR:23478 Expected: an empty string. Got: " + include.getIncludeName()); } } } @@ -122,6 +119,7 @@ public void testBug23478A() throws Exception { /*************************************************************************** * Simple sanity tests for the getIncludes call */ + @Test public void testBug23478B() throws Exception { String headers[] = { "stdio.h", "unistd.h" }; ExpectedStrings myExp = new ExpectedStrings(headers); @@ -133,8 +131,8 @@ public void testBug23478B() throws Exception { } // Failed test: Include.getIncludeName() always returns ""; // assertTrue - assertTrue(myExp.getMissingString(), myExp.gotAll()); - assertTrue(myExp.getExtraString(), !myExp.gotExtra()); + Assertions.assertTrue(myExp.gotAll(), myExp.getMissingString()); + Assertions.assertTrue(!myExp.gotExtra(), myExp.getExtraString()); } /*************************************************************************** @@ -170,11 +168,12 @@ public void testBug23478B() throws Exception { // } // } + @Test public void testIsValidSourceUnitName() { - assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.c")); - assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.h")); - assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.cc")); - assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.hh")); + Assertions.assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.c")); + Assertions.assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.h")); + Assertions.assertTrue(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.cc")); + Assertions.assertFalse(CoreModel.isValidSourceUnitName(testProject.getProject(), "test.hh")); } // This test is disabled because it fails consistently due to a collision between content types diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java index db8445b6ed7..a8a448eb18a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/model/tests/WorkingCopyTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.model.tests; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -24,41 +29,24 @@ import org.eclipse.cdt.core.model.IWorkingCopy; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.TestPluginLauncher; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Path; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Contains unit test cases for Working Copies. Run using JUnit Plugin Test * configuration launcher. */ -public class WorkingCopyTests extends TestCase { +public class WorkingCopyTests { private ICProject fCProject; private IFile headerFile; private NullProgressMonitor monitor; - public static void main(String[] args) { - TestPluginLauncher.run(TestPluginLauncher.getLocationFromProperties(), WorkingCopyTests.class, args); - } - - public static Test suite() { - TestSuite suite = new TestSuite(WorkingCopyTests.class.getName()); - suite.addTest(new WorkingCopyTests("testWorkingCopy")); - //suite.addTest(new WorkingCopyTests("testHashing")); - return suite; - } - - public WorkingCopyTests(String name) { - super(name); - } - - @Override + @BeforeEach protected void setUp() throws Exception { monitor = new NullProgressMonitor(); @@ -78,11 +66,12 @@ protected void setUp() throws Exception { } } - @Override + @AfterEach protected void tearDown() { CProjectHelper.delete(fCProject); } + @Test public void testWorkingCopy() throws Exception { ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(headerFile); // CreateWorkingCopy diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java index 31e1ddd5b07..04cb76f62e5 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/BackwardCompatibilityTests.java @@ -13,6 +13,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashSet; @@ -26,28 +31,20 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IPathEntry; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestSuite; - -public class BackwardCompatibilityTests extends BaseTestCase { +public class BackwardCompatibilityTests extends BaseTestCase5 { private static final String PROJ_NAME_PREFIX = "BackwardCompatibilityTests_"; ICProject p1, p2, p3; - public static TestSuite suite() { - return suite(BackwardCompatibilityTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { - } - - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProjects() throws Exception { try { if (p1 != null) { p1.getProject().delete(true, null); @@ -65,6 +62,7 @@ protected void tearDown() throws Exception { } } + @Test public void testPathEntriesForNewStyle() throws Exception { p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", TestUserAndDiscoveredEntriesCfgDataProvider.PROVIDER_ID, IPDOMManager.ID_NO_INDEXER); @@ -170,6 +168,7 @@ public void testPathEntriesForNewStyle() throws Exception { checkEntriesMatch(expectedResolvedEntries, resolvedentries); } + @Test public void testCPathEntriesForOldStyle() throws Exception { p2 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "b", null, IPDOMManager.ID_NO_INDEXER); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -214,6 +213,7 @@ public void testCPathEntriesForOldStyle() throws Exception { checkCEntriesMatch(expectedOutputEntries, oEntries); } + @Test public void testICDescriptorGetProjectData() throws Exception { p3 = CProjectHelper.createCCProject(PROJ_NAME_PREFIX + "c", null, IPDOMManager.ID_NO_INDEXER); IProject proj = p3.getProject(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java index add611d7b67..7ea15627e1a 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionExportSettingsTests.java @@ -14,6 +14,11 @@ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -24,7 +29,7 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -32,22 +37,17 @@ import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Class for testing exported settings and project references. * This functionality is provided by the CfgExportSettingContainerFactory which plugins * into the CExternalSettingsManager */ -public class CConfigurationDescriptionExportSettingsTests extends BaseTestCase { +public class CConfigurationDescriptionExportSettingsTests extends BaseTestCase5 { CoreModel coreModel = CoreModel.getDefault(); - public static TestSuite suite() { - return suite(CConfigurationDescriptionExportSettingsTests.class, "_"); - } - // Setting entries 1 final ICLanguageSettingEntry entries[] = new ICLanguageSettingEntry[] { new CMacroEntry("a", "b", 0), new CMacroEntry("c", "d", 0), new CIncludePathEntry("a/b/c", 0), new CIncludePathEntry("d/e/f", 0), }; @@ -61,6 +61,7 @@ public static TestSuite suite() { * It used to live in the Managedbuild testsuite in ProjectModelTests.java * but is moved here as it doesn't test any managedbuilder specific functionality */ + @Test public void testReferences() throws Exception { final String projectName4 = "test4"; final String projectName5 = "test5"; @@ -126,6 +127,7 @@ public void testReferences() throws Exception { * imported in opposite order * @throws Exception */ + @Test public void testProjectImport() throws Exception { final IProject libProj = ResourceHelper.createCDTProjectWithConfig("libProj"); final IProject mainProj = ResourceHelper.createCDTProjectWithConfig("mainProj"); @@ -189,6 +191,7 @@ public void testProjectImport() throws Exception { * of references, is correctly picked up in referencing projects. * https://bugs.eclipse.org/bugs/show_bug.cgi?id=312575 */ + @Test public void testUpdateExportedSettingsActiveCfg() throws Exception { final IProject libProj = ResourceHelper.createCDTProjectWithConfig("libUpdateExtSettings"); final IProject mainProj = ResourceHelper.createCDTProjectWithConfig("mainProjUpdateExtSettings"); @@ -249,6 +252,7 @@ public void testUpdateExportedSettingsActiveCfg() throws Exception { * Tests that updating the exported settings on a name configuration, without updating the set * of references, is correctly picked up in referencing projects */ + @Test public void testUpdateExportedSettingsNamedConfig() throws Exception { final IProject libProj = ResourceHelper.createCDTProjectWithConfig("libUpdateExpSettingsNamed"); final IProject mainProj = ResourceHelper.createCDTProjectWithConfig("mainProjUpdateExpSettingsNamed"); @@ -308,6 +312,7 @@ public void testUpdateExportedSettingsNamedConfig() throws Exception { * causes referencing projects to correctly pick up changes to the project exports. * https://bugs.eclipse.org/bugs/show_bug.cgi?id=312575 */ + @Test public void testExportedSettingsExternalUpdate() throws Exception { final IProject libProj = ResourceHelper.createCDTProjectWithConfig("libProj312575"); final IProject mainProj = ResourceHelper.createCDTProjectWithConfig("mainProj312575"); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java index 9a2987efbfb..1e6e00b3d0e 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CConfigurationDescriptionReferenceTests.java @@ -14,6 +14,9 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; @@ -26,27 +29,24 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.settings.model.extension.impl.CDefaultConfigurationData; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.runtime.CoreException; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Test ICConfigurationDescription reference behaviours */ -public class CConfigurationDescriptionReferenceTests extends BaseTestCase { +public class CConfigurationDescriptionReferenceTests extends BaseTestCase5 { ICProject p1, p2, p3, p4; ICConfigurationDescription p1cd1, p1cd2, p1cd3; ICConfigurationDescription p2cd1, p2cd2, p2cd3; ICConfigurationDescription p3cd1, p3cd2, p3cd3; ICConfigurationDescription p4cd1, p4cd2, p4cd3; - public static TestSuite suite() { - return suite(CConfigurationDescriptionReferenceTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProjects() throws Exception { p1 = CProjectHelper.createCCProject("p1", "bin"); p2 = CProjectHelper.createCCProject("p2", "bin"); p3 = CProjectHelper.createCCProject("p3", "bin"); @@ -126,6 +126,7 @@ private ICConfigurationDescription newCfg(ICProjectDescription des, String proje return des.createConfiguration(CCorePlugin.DEFAULT_PROVIDER_ID, data); } + @Test public void testConfigurationDescriptionReference() throws CoreException { // references @@ -146,6 +147,7 @@ public void testConfigurationDescriptionReference() throws CoreException { assertEdges(p4cd3, new ICConfigurationDescription[] {}, true); } + @Test public void testConfigurationDescriptionReferencing() throws CoreException { // referencing @@ -169,6 +171,7 @@ public void testConfigurationDescriptionReferencing() throws CoreException { /** * Test that the the referencing mechanism preserves order */ + @Test public void testDependencyOrder() throws CoreException { ICProject p1 = null; ICProject p2 = null; @@ -253,12 +256,12 @@ protected void assertEdges(ICConfigurationDescription cfgDes, ICConfigurationDes } // check for each ID, don't use a Set so we detect duplicates for (ICConfigurationDescription element : expected) { - assertTrue(element.getId() + " is missing", actualIds.contains(element.getId())); + assertTrue(actualIds.contains(element.getId()), element.getId() + " is missing"); } } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void cleanUp() throws Exception { for (Object element : Arrays.asList(new ICProject[] { p1, p2, p3, p4 })) { ICProject project = (ICProject) element; try { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java index c6ff685dfa3..6b300659834 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionDeltaTests.java @@ -13,6 +13,13 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -26,13 +33,13 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.ResourceHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestSuite; - -public class CProjectDescriptionDeltaTests extends BaseTestCase { +public class CProjectDescriptionDeltaTests extends BaseTestCase5 { private MockListener listener; @@ -69,16 +76,8 @@ public ICDescriptionDelta getDelta() { } } - public static TestSuite suite() { - return suite(CProjectDescriptionDeltaTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { - } - - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void cleanUp() throws Exception { ResourceHelper.cleanUp(getName()); } @@ -106,6 +105,7 @@ private static List findDeltas(ICDescriptionDelta delta, int return list; } + @Test public void testDelta_ACTIVE_CFG() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -154,6 +154,7 @@ public void testDelta_ACTIVE_CFG() throws Exception { assertEquals(cfgDescription1.getName(), newSetting.getActiveConfiguration().getName()); } + @Test public void testDelta_NAME() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -197,6 +198,7 @@ public void testDelta_NAME() throws Exception { assertEquals(newName, newSetting.getName()); } + @Test public void testDelta_DESCRIPTION() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -240,6 +242,7 @@ public void testDelta_DESCRIPTION() throws Exception { } + @Test public void testDelta_LANGUAGE_ID() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -287,6 +290,7 @@ public void testDelta_LANGUAGE_ID() throws Exception { } + @Test public void testDelta_SOURCE_CONTENT_TYPE() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -333,6 +337,7 @@ public void testDelta_SOURCE_CONTENT_TYPE() throws Exception { } + @Test public void testDelta_SOURCE_EXTENSIONS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -383,6 +388,7 @@ public void testDelta_SOURCE_EXTENSIONS() throws Exception { } + @Test public void testDelta_SETTING_ENTRIES() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -430,6 +436,7 @@ public void testDelta_SETTING_ENTRIES() throws Exception { assertTrue(newSettingEntries.contains(testSettingEntry)); } + @Test public void testDelta_BINARY_PARSER_IDS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -476,6 +483,7 @@ public void testDelta_BINARY_PARSER_IDS() throws Exception { } + @Test public void testDelta_ERROR_PARSER_IDS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -521,6 +529,7 @@ public void testDelta_ERROR_PARSER_IDS() throws Exception { } + @Test public void testDelta_EXCLUDE() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -584,6 +593,7 @@ public void testDelta_EXCLUDE() throws Exception { } + @Test public void testDelta_SOURCE_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -631,6 +641,7 @@ public void testDelta_SOURCE_ADDED() throws Exception { assertTrue(newSourceEntries.contains(testSourceEntry)); } + @Test public void testDelta_SOURCE_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -693,6 +704,7 @@ public void testDelta_SOURCE_REMOVED() throws Exception { } + @Test public void testDelta_EXTERNAL_SETTINGS_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -740,6 +752,7 @@ public void testDelta_EXTERNAL_SETTINGS_ADDED() throws Exception { assertTrue(newSettingEntries.contains(testSettingEntry)); } + @Test public void testDelta_EXTERNAL_SETTINGS_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -801,6 +814,7 @@ public void testDelta_EXTERNAL_SETTINGS_REMOVED() throws Exception { } + @Test public void testDelta_CFG_REF_ADDED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -849,6 +863,7 @@ public void testDelta_CFG_REF_ADDED() throws Exception { assertEquals(testValue, newReferenceInfo.get(testKey)); } + @Test public void testDelta_CFG_REF_REMOVED() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -879,7 +894,7 @@ public void testDelta_CFG_REF_REMOVED() throws Exception { assertNotNull(cfgDescription); // Modification CFG_REF_REMOVED - cfgDescription.setReferenceInfo(new HashMap()); + cfgDescription.setReferenceInfo(new HashMap<>()); // Write project description listener.clearNotified(); @@ -911,6 +926,7 @@ public void testDelta_CFG_REF_REMOVED() throws Exception { } + @Test public void testDelta_EXT_REF() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -958,6 +974,7 @@ public void testDelta_EXT_REF() throws Exception { assertTrue(newBinaryParserIds.contains(testBinaryParserId)); } + @Test public void testDelta_INDEX_CFG() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -1009,6 +1026,7 @@ public void testDelta_INDEX_CFG() throws Exception { assertEquals(cfgDescription1.getName(), newSetting.getDefaultSettingConfiguration().getName()); } + @Test public void testDelta_LANGUAGE_SETTINGS_PROVIDERS() throws Exception { String projName = getName(); ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java index 2f895030f48..1dd9725c207 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionStorageTests.java @@ -14,6 +14,11 @@ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -26,7 +31,7 @@ import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; @@ -43,35 +48,32 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.preferences.InstanceScope; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; /** * Testsuite for the project description storage. This * currently tests some of the features of the built-in * XmlProjectDescriptionStorage(2) */ -public class CProjectDescriptionStorageTests extends BaseTestCase { +public class CProjectDescriptionStorageTests extends BaseTestCase5 { /** CProject on which these tests are based */ ICProject cProj; - public static TestSuite suite() { - return suite(CProjectDescriptionStorageTests.class, "_"); - } - // resource change listener that will listen for file changes interesting to the tests OurResourceChangeListener resListener; - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProject() throws Exception { cProj = CProjectHelper.createNewStyleCProject("CProjDescStorage", IPDOMManager.ID_FAST_INDEXER); resListener = new OurResourceChangeListener(); ResourcesPlugin.getWorkspace().addResourceChangeListener(resListener); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { // Remover our resource change listener ResourcesPlugin.getWorkspace().removeResourceChangeListener(resListener); // Make the project files writable so they can be deleted... @@ -92,6 +94,7 @@ protected void tearDown() throws Exception { * Tests that external modifications to the CProjectDescription file are picked up * @throws Exception */ + @Test public void testExternalCProjDescModification() throws Exception { // Create auto-refresh Thread Job refreshJob = new Job("Auto-Refresh") { @@ -183,6 +186,7 @@ protected IStatus run(IProgressMonitor monitor) { * (Bug 311189) * @throws Exception */ + @Test public void testExternalCProjDescRemoveAndReplace() throws Exception { // Create auto-refresh Thread Job refreshJob = new Job("Auto-Refresh") { @@ -249,6 +253,7 @@ protected IStatus run(IProgressMonitor monitor) { * Tests that a read-only project description file is picked up * @throws Exception */ + @Test public void testReadOnlyProjectDescription() throws Exception { enableSetWritableWhenHeadless(true); try { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java index fbb4e74fac7..de4a90ee342 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java @@ -13,28 +13,26 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestSuite; - -public class CfgSettingsTests extends BaseTestCase { +public class CfgSettingsTests extends BaseTestCase5 { private static final String PROJ_NAME_PREFIX = "sfgst_"; ICProject p1; - public static TestSuite suite() { - return suite(CfgSettingsTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { - } - + @Test public void testDefaultSettingConfig() throws Exception { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); @@ -151,8 +149,8 @@ private int getChangedConfigRelStatus(int status) { return ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT; } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProject() throws Exception { try { if (p1 != null) { p1.getProject().delete(true, null); diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java index dd9e1fc7a95..d434b5ac4d1 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ExternalSettingsProviderTests.java @@ -18,6 +18,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -29,23 +34,20 @@ import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.CProjectHelper; import org.eclipse.cdt.core.testplugin.CTestPlugin; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestSuite; - -public class ExternalSettingsProviderTests extends BaseTestCase { +public class ExternalSettingsProviderTests extends BaseTestCase5 { private static final String PROJ_NAME_PREFIX = "espt_"; ICProject p1, p2, p3, p4, p5, p6; - public static TestSuite suite() { - return suite(ExternalSettingsProviderTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { + @BeforeEach + protected void createProjects() throws Exception { p1 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); p2 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "b", IPDOMManager.ID_NO_INDEXER); p3 = CProjectHelper.createNewStyleCProject(PROJ_NAME_PREFIX + "c", IPDOMManager.ID_NO_INDEXER); @@ -58,6 +60,7 @@ protected void setUp() throws Exception { * Test adding a external setting provider to p1 -- the contributed paths should appear * @throws Exception */ + @Test public void testRefs() throws Exception { TestExtSettingsProvider.setVariantNum(0); CoreModel model = CoreModel.getDefault(); @@ -122,6 +125,7 @@ public void testRefs() throws Exception { assertTrue(Arrays.equals(expectedEntries, entries)); } + @Test public void testCreateCfg() throws Exception { TestExtSettingsProvider.setVariantNum(0); CoreModel model = CoreModel.getDefault(); @@ -165,6 +169,7 @@ public void testCreateCfg() throws Exception { } + @Test public void testProviderUpdate() throws Exception { TestExtSettingsProvider.setVariantNum(0); @@ -211,6 +216,7 @@ public void testProviderUpdate() throws Exception { assertTrue(Arrays.equals(expectedEntries2, entries)); } + @Test public void testRestoreDefaults() throws Exception { TestExtSettingsProvider.setVariantNum(0); @@ -272,6 +278,7 @@ public void testRestoreDefaults() throws Exception { /** * Test that all entries are present */ + @Test public void testCheckAllProvidedSettingTypes() throws CoreException { TestExtSettingsProvider.setVariantNum(0); CoreModel model = CoreModel.getDefault(); @@ -340,6 +347,7 @@ private ICSettingEntry[] makeProjectRelativePath(IProject project, ICSettingEntr /** * Test if changing only the language IDs of an external setting works */ + @Test public void testChangeLanguageSet() throws CoreException { TestExtSettingsProvider.setVariantNum(2); @@ -412,6 +420,7 @@ public void testChangeLanguageSet() throws CoreException { /** * Test if moving an entry to an external setting with different language IDs works */ + @Test public void testChangeLanguageSetMove() throws CoreException { TestExtSettingsProvider.setVariantNum(5); @@ -489,6 +498,7 @@ public void testChangeLanguageSetMove() throws CoreException { * Test if macros with the same name but different values can coexist when * they belong to different language ids */ + @Test public void testSameMacroWithDifferentValuesAndDifferentLanguageIds() throws CoreException { TestExtSettingsProvider.setVariantNum(4); @@ -520,8 +530,8 @@ public void testSameMacroWithDifferentValuesAndDifferentLanguageIds() throws Cor } } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void deleteProjects() throws Exception { try { p1.getProject().delete(true, null); } catch (CoreException e) { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java index c20952bdfb8..9f26edd7a48 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/PathSettingsContainerTests.java @@ -14,29 +14,25 @@ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import org.eclipse.cdt.core.settings.model.util.PathSettingsContainer; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** */ -public class PathSettingsContainerTests extends BaseTestCase { - - public static TestSuite suite() { - return suite(PathSettingsContainerTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { - } - - @Override - protected void tearDown() throws Exception { - } +public class PathSettingsContainerTests extends BaseTestCase5 { + @Test public void testPathSettingsContainerCreate() { final PathSettingsContainer root = PathSettingsContainer.createRootContainer(); assertNull(root.getValue()); @@ -93,6 +89,7 @@ public void testPathSettingsContainerCreate() { assertSame(child3, root.getChildContainer(level3, true, true)); } + @Test public void testPathSettingsContainerRemove() { final PathSettingsContainer root = PathSettingsContainer.createRootContainer(); final IPath level1 = new Path("level1"); @@ -117,6 +114,7 @@ public void testPathSettingsContainerRemove() { } + @Test public void testPathSettingsContainer_Bug208765() { final PathSettingsContainer root = PathSettingsContainer.createRootContainer(); try { diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java index b3e82525e76..ff413036d47 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/ProjectCreationStateTests.java @@ -13,22 +13,27 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.dom.IPDOMManager; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase5; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestSuite; - -public class ProjectCreationStateTests extends BaseTestCase { +public class ProjectCreationStateTests extends BaseTestCase5 { private static final String PROJ_NAME_PREFIX = "ProjectCreationStateTests_"; private IProject p1, p2, p3, p4; @@ -91,15 +96,6 @@ void resetNotified() { } - public static TestSuite suite() { - return suite(ProjectCreationStateTests.class, "_"); - } - - @Override - protected void setUp() throws Exception { - // p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); - } - private void initListener(String projName) { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); if (listener != null) @@ -113,6 +109,7 @@ private void initListener(String projName) { } + @Test public void testProjectCreatingState() throws Exception { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); String projName = PROJ_NAME_PREFIX + "a"; @@ -179,6 +176,7 @@ public void testProjectCreatingState() throws Exception { listener.resetNotified(); } + @Test public void testCreateProjectDescriptionForInexistingDes() throws Exception { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); String projName = PROJ_NAME_PREFIX + "b"; @@ -242,6 +240,7 @@ public void testCreateProjectDescriptionForInexistingDes() throws Exception { assertTrue(listener.isCreating()); } + @Test public void testCreateProjectDescriptionForCreatingDes() throws Exception { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); String projName = PROJ_NAME_PREFIX + "c"; @@ -302,6 +301,7 @@ public void testCreateProjectDescriptionForCreatingDes() throws Exception { assertTrue(listener.isCreating()); } + @Test public void testCreateProjectDescriptionForCreatedDes() throws Exception { ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); String projName = PROJ_NAME_PREFIX + "d"; @@ -362,8 +362,8 @@ public void testCreateProjectDescriptionForCreatedDes() throws Exception { assertFalse(listener.isCreating()); } - @Override - protected void tearDown() throws Exception { + @AfterEach + protected void cleanUp() throws Exception { if (listener != null) { CoreModel.getDefault().getProjectDescriptionManager().removeCProjectDescriptionListener(listener); listener = null; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java index 6b364c92ee6..4a17e173aa1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ArrayUtilTest.java @@ -14,16 +14,21 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests; -import org.eclipse.cdt.core.parser.util.ArrayUtil; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; -import junit.framework.TestCase; +import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.junit.jupiter.api.Test; -public class ArrayUtilTest extends TestCase { +public class ArrayUtilTest { private final Object o1 = new Object(); private final Object o2 = new Object(); private final Object o3 = new Object(); private final Object o4 = new Object(); + @Test public void testAppend() { Object[] array = null; array = ArrayUtil.append(array, o1); @@ -41,6 +46,7 @@ public void testAppend() { assertEquals(o3, array[2]); } + @Test public void testPrepend() { Object[] array = null; array = ArrayUtil.prepend(Object.class, array, o1); @@ -51,6 +57,7 @@ public void testPrepend() { assertEquals(o1, array[2]); } + @Test public void testTrim() { Object[] array = new Object[] { null, null }; array = ArrayUtil.trim(Object.class, array); @@ -85,6 +92,7 @@ public void testTrim() { assertNotSame(array, array2); } + @Test public void testAddAll() { Object[] array1 = { o1, o2, null }; Object[] array2 = { o3, null }; @@ -150,6 +158,7 @@ public void testAddAll() { assertEquals("s", result[2]); } + @Test public void testRemove() { Object[] array = new Object[] { o1, o2, o3, o4, null }; ArrayUtil.remove(array, o3); @@ -190,6 +199,7 @@ public void testRemove() { assertNull(array[0]); } + @Test public void testRemoveNulls() { Object[] array = new Object[0]; Object[] result; @@ -244,6 +254,7 @@ public void testRemoveNulls() { assertSame(result[1], o2); } + @Test public void testRemoveDuplicates() { String[] array = { "1", "2", null, "3", "2", "1", "4", "3" }; String[] result = ArrayUtil.removeDuplicates(array); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java index 10804f9ac62..0566f53a573 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayObjectMapTest.java @@ -13,17 +13,20 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.Random; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; - -import junit.framework.TestCase; +import org.junit.jupiter.api.Test; /** * Tests for {@link CharArrayObjectMap}. */ -public class CharArrayObjectMapTest extends TestCase { +public class CharArrayObjectMapTest { + @Test public void testMapAdd() { CharArrayObjectMap map = new CharArrayObjectMap(4); char[] key1 = "key1".toCharArray(); @@ -44,6 +47,7 @@ public void testMapAdd() { } } + @Test public void testDuplicates() { CharArrayObjectMap map = new CharArrayObjectMap(4); String[] keys = new String[] { "a", "b", "c", "c", "value", "value", "context", "context", "result", "d", "e", @@ -62,6 +66,7 @@ public void testDuplicates() { } } + @Test public void testCollisionRatio() { Random random = new Random(239); CharArrayObjectMap map = new CharArrayObjectMap(1); @@ -69,8 +74,8 @@ public void testCollisionRatio() { int r = random.nextInt(); map.put(("key" + Integer.toUnsignedString(i)).toCharArray(), i); double collisionRatio = (double) map.countCollisions() / map.size(); - assertTrue(String.format("Collision ratio %.3f is unexpectedly high for map size of %d.", collisionRatio, - map.size()), collisionRatio <= 0.4); + assertTrue(collisionRatio <= 0.4, String.format( + "Collision ratio %.3f is unexpectedly high for map size of %d.", collisionRatio, map.size())); } } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java index 914a80005ca..13b29bd21e8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/CharArrayUtilsTest.java @@ -14,15 +14,19 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import junit.framework.TestCase; +import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.junit.jupiter.api.Test; /** * @author Doug Schaefer */ -public class CharArrayUtilsTest extends TestCase { +public class CharArrayUtilsTest { + @Test public void testEquals_Bug289852() { assertTrue(CharArrayUtils.equals("pre_abc".toCharArray(), 4, 3, "abc".toCharArray(), false)); assertFalse(CharArrayUtils.equals("pre_abc".toCharArray(), 4, 4, "abcd".toCharArray(), false)); @@ -33,6 +37,7 @@ public void testEquals_Bug289852() { assertTrue(CharArrayUtils.equals("pre_abc".toCharArray(), 4, 2, "AB".toCharArray(), true)); } + @Test public void testTrim() { assertEquals("", new String(CharArrayUtils.trim("".toCharArray()))); assertEquals("", new String(CharArrayUtils.trim(" ".toCharArray()))); @@ -42,6 +47,7 @@ public void testTrim() { assertEquals("a b", new String(CharArrayUtils.trim("a b ".toCharArray()))); } + @Test public void testLastIndexOf() { assertEquals(-1, CharArrayUtils.lastIndexOf('a', "".toCharArray())); assertEquals(3, CharArrayUtils.lastIndexOf('a', "array".toCharArray())); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java index 1ea575e45a8..805b0aa703d 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ContentAssistMatcherFactoryTest.java @@ -15,19 +15,23 @@ package org.eclipse.cdt.core.parser.tests; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + import org.eclipse.cdt.core.parser.util.IContentAssistMatcher; import org.eclipse.cdt.internal.core.parser.util.ContentAssistMatcherFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Test; -import junit.framework.TestCase; - -public class ContentAssistMatcherFactoryTest extends TestCase { +public class ContentAssistMatcherFactoryTest { - @Override + @AfterEach protected void tearDown() throws Exception { ContentAssistMatcherFactory.getInstance().setShowCamelCaseMatches(true); - super.tearDown(); } + @Test public void testConfiguration() { // Default is show camel case matches on assertTrue(match("foo", "fooBar")); @@ -44,6 +48,7 @@ public void testConfiguration() { assertTrue(match("fB", "fooBar")); } + @Test public void testCamelCaseMatcher() { setShowCamelCaseMatches(true); IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher("fB"); @@ -52,6 +57,7 @@ public void testCamelCaseMatcher() { assertTrue(matcher.matchRequiredAfterBinarySearch()); } + @Test public void testPrefixMatcher() { setShowCamelCaseMatches(true); IContentAssistMatcher matcher = ContentAssistMatcherFactory.getInstance().createMatcher("foo"); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java index 2b1de871409..73e5d84641b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/FileBasePluginTestCase.java @@ -26,13 +26,123 @@ import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.NullProgressMonitor; - -import junit.framework.TestCase; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; /** * @author dsteffle */ -public abstract class FileBasePluginTestCase extends TestCase { +public abstract class FileBasePluginTestCase { + + public static void assertNotEquals(Object expected, Object actual) { + Assertions.assertNotEquals(expected, actual); + } + + public static void assertNotEquals(String msg, Object expected, Object actual) { + Assertions.assertNotEquals(expected, actual, msg); + } + + public static void assertNotEquals(String msg, long expected, long actual) { + Assertions.assertNotEquals(expected, actual, msg); + } + + public static void assertNotEquals(long expected, long actual) { + Assertions.assertNotEquals(expected, actual); + } + + public static void assertEquals(Object expected, Object actual) { + Assertions.assertEquals(expected, actual); + } + + public static void assertEquals(String msg, Object expected, Object actual) { + Assertions.assertEquals(expected, actual, msg); + } + + public static void assertEquals(long expected, long actual) { + Assertions.assertEquals(expected, actual); + } + + public static void assertEquals(String msg, long expected, long actual) { + Assertions.assertEquals(expected, actual, msg); + } + + public static void assertEquals(double a, double b, double c) { + Assertions.assertEquals(a, b, c); + } + + public static void assertEquals(String msg, double a, double b, double c) { + Assertions.assertEquals(a, b, c, msg); + } + + public static void assertEquals(float a, float b, float c) { + Assertions.assertEquals(a, b, c); + } + + public static void assertEquals(String msg, float a, float b, float c) { + Assertions.assertEquals(a, b, c, msg); + } + + public static void assertSame(Object expected, Object actual) { + Assertions.assertSame(expected, actual); + } + + public static void assertSame(String msg, Object expected, Object actual) { + Assertions.assertSame(expected, actual, msg); + } + + public static void assertNotSame(Object expected, Object actual) { + Assertions.assertNotSame(expected, actual); + } + + public static void assertNotSame(String msg, Object expected, Object actual) { + Assertions.assertNotSame(expected, actual, msg); + } + + public static void assertNull(Object object) { + Assertions.assertNull(object); + } + + public static void assertNull(String msg, Object object) { + Assertions.assertNull(object, msg); + } + + public static void assertNotNull(Object object) { + Assertions.assertNotNull(object); + } + + public static void assertNotNull(String msg, Object object) { + Assertions.assertNotNull(object, msg); + } + + public static void assertTrue(boolean n) { + Assertions.assertTrue(n); + } + + public static void assertTrue(String msg, boolean n) { + Assertions.assertTrue(n, msg); + } + + public static void assertFalse(boolean n) { + Assertions.assertFalse(n); + } + + public static void assertFalse(String msg, boolean n) { + Assertions.assertFalse(n, msg); + } + + public static void fail() { + Assertions.fail(); + } + + public static void fail(String msg) { + Assertions.fail(msg); + } + + public static void assertArrayEquals() { + fail("TODO"); + } + static NullProgressMonitor monitor; static IWorkspace workspace; static IProject project; @@ -41,9 +151,8 @@ public abstract class FileBasePluginTestCase extends TestCase { static ICProject cPrj; private Class className2; - @Override + @BeforeEach protected void setUp() throws Exception { - super.setUp(); monitor = new NullProgressMonitor(); workspace = ResourcesPlugin.getWorkspace(); @@ -53,7 +162,7 @@ protected void setUp() throws Exception { assertNotNull(project); } - @Override + @AfterEach protected void tearDown() throws Exception { if (project == null || !project.exists()) return; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java index 963eb2d6886..cdb57d59d9b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ObjectMapTest.java @@ -17,14 +17,15 @@ */ package org.eclipse.cdt.core.parser.tests; -import org.eclipse.cdt.core.parser.util.ObjectMap; +import static org.junit.jupiter.api.Assertions.assertEquals; -import junit.framework.TestCase; +import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.junit.jupiter.api.Test; /** * Tests for {@link ObjectMap}. */ -public class ObjectMapTest extends TestCase { +public class ObjectMapTest { private static class HashObject { final public int hash; @@ -54,6 +55,7 @@ public void assertContents(ObjectMap map, Object[][] contents) throws Exception assertEquals(map.size(), contents.length); } + @Test public void testSimpleAdd() throws Exception { ObjectMap map = new ObjectMap(2); @@ -66,6 +68,7 @@ public void testSimpleAdd() throws Exception { assertEquals(map.capacity(), 8); } + @Test public void testSimpleCollision() throws Exception { ObjectMap map = new ObjectMap(2); @@ -82,6 +85,7 @@ public void testSimpleCollision() throws Exception { assertContents(map, contents); } + @Test public void testResize() throws Exception { ObjectMap map = new ObjectMap(1); @@ -95,6 +99,7 @@ public void testResize() throws Exception { assertContents(map, res); } + @Test public void testCollisionResize() throws Exception { ObjectMap map = new ObjectMap(1); @@ -109,6 +114,7 @@ public void testCollisionResize() throws Exception { assertContents(map, res); } + @Test public void testReAdd() throws Exception { ObjectMap map = new ObjectMap(1); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java index e20613b8ab0..1d93ccedbff 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/SegmentMatcherTest.java @@ -15,12 +15,16 @@ package org.eclipse.cdt.core.parser.tests; -import org.eclipse.cdt.core.parser.util.SegmentMatcher; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; -import junit.framework.TestCase; +import org.eclipse.cdt.core.parser.util.SegmentMatcher; +import org.junit.jupiter.api.Test; -public class SegmentMatcherTest extends TestCase { +public class SegmentMatcherTest { + @Test public void testSimple() { assertTrue(matchSegments("", "fooBarBaz")); @@ -55,6 +59,7 @@ public void testSimple() { } + @Test public void testSuffix() { assertTrue(matchSegments("fooBar", "fooBar123")); @@ -63,6 +68,7 @@ public void testSuffix() { } + @Test public void testNumeric() { assertTrue(matchSegments("fBBaz", "foo29BarBaz")); @@ -78,6 +84,7 @@ public void testNumeric() { } + @Test public void testSeparator() { assertTrue(matchSegments("fBB", "foo_Bar_Baz")); @@ -104,6 +111,7 @@ public void testSeparator() { } + @Test public void testPrefixChars() { assertFalse(matchSegments("$asd", "_asd")); @@ -125,17 +133,20 @@ public void testPrefixChars() { } + @Test public void testAbbreviations() { assertTrue(matchSegments("IFB", "IFooBar")); assertTrue(matchSegments("IFoB", "IFooBar")); assertTrue(matchSegments("XYZ", "XYZFooBar")); } + @Test public void testSingleSegment() { assertTrue(matchSegments("foo", "fooBar")); assertFalse(matchSegments("bar", "fooBar")); } + @Test public void testGetPrefixForBinarySearch() { // Segments can be skipped, because of that the first letter as well // as the leading separator must not be added to the binary search prefix. diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java index 0b56d380d5c..ed53890910b 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPAttributeTests.java @@ -15,6 +15,11 @@ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.util.ArrayList; import java.util.List; @@ -58,22 +63,10 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.cdt.internal.core.dom.parser.ASTTokenList; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; public class AST2CPPAttributeTests extends AST2TestBase { - public AST2CPPAttributeTests() { - } - - public AST2CPPAttributeTests(String name) { - super(name); - } - - public static TestSuite suite() { - return suite(AST2CPPAttributeTests.class); - } - private IASTTranslationUnit parseAndCheckBindings() throws Exception { String code = getAboveComment(); return parseAndCheckBindings(code, ParserLanguage.CPP); @@ -154,18 +147,21 @@ private void checkAttributeRelations(List specifiers, } // auto t = []() mutable throw(char const *) [[attr]] { throw "exception"; }; + @Test public void testAttributedLambda() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTFunctionDeclarator.class); } // int * arr = new int[1][[attr]]{2}; + @Test public void testAttributedNewArrayExpression() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTArrayModifier.class); } // int (* matrix) = new int[2][[attr1]][2][[attr2]]; + @Test public void testAttributedMultidimensionalNewArrayExpression() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); List specifiers = getAttributeSpecifiers(tu); @@ -180,6 +176,7 @@ public void testAttributedMultidimensionalNewArrayExpression() throws Exception // void foo() { // [[attr]] label:; // } + @Test public void testAttributeInLabeledStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTLabelStatement.class); @@ -192,6 +189,7 @@ public void testAttributeInLabeledStatement() throws Exception { // ; // } // } + @Test public void testAttributedSwitchLabels() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); List specifiers = getAttributeSpecifiers(tu); @@ -202,6 +200,7 @@ public void testAttributedSwitchLabels() throws Exception { // int i{0}; // [[attr]] i++; // } + @Test public void testAttributedExpressionStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTExpressionStatement.class); @@ -210,6 +209,7 @@ public void testAttributedExpressionStatement() throws Exception { // void foo() { // [[attr]] {} // } + @Test public void testAttributedCompoundStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTCompoundStatement.class); @@ -218,6 +218,7 @@ public void testAttributedCompoundStatement() throws Exception { // void foo() { // [[attr]] if(false); // } + @Test public void testAttributedSelectionStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTIfStatement.class); @@ -226,6 +227,7 @@ public void testAttributedSelectionStatement() throws Exception { // void foo() { // [[attr]] while(false); // } + @Test public void testAttributedIterationStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTWhileStatement.class); @@ -234,6 +236,7 @@ public void testAttributedIterationStatement() throws Exception { // void foo() { // [[attr]] return; // } + @Test public void testAttributedJumpStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTReturnStatement.class); @@ -242,6 +245,7 @@ public void testAttributedJumpStatement() throws Exception { // void foo() { // [[attr]] try{} catch(...) {} // } + @Test public void testAttributedTryBlockStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTTryBlockStatement.class); @@ -250,6 +254,7 @@ public void testAttributedTryBlockStatement() throws Exception { // void foo() { // if([[attr]]int i{0}); // } + @Test public void testAttributedConditionWithInitializer() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); @@ -259,18 +264,21 @@ public void testAttributedConditionWithInitializer() throws Exception { // int a[1]{0}; // for([[attr]]auto i : a){} // } + @Test public void testAttributedForRangeDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); } // using number [[attr]] = int; + @Test public void testAttributedAliasDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTAliasDeclaration.class); } // enum [[attr]] e {}; + @Test public void testAttributedEnumDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTEnumerationSpecifier.class); @@ -278,6 +286,7 @@ public void testAttributedEnumDeclaration() throws Exception { // namespace NS{} // [[attr]] using namespace NS; + @Test public void testAttributedUsingDirective() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTUsingDirective.class); @@ -286,6 +295,7 @@ public void testAttributedUsingDirective() throws Exception { // void foo() throw(char const *) [[noreturn]] -> void { // throw "exception"; // } + @Test public void testTrailingNoreturnFunctionDefinition() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); @@ -294,60 +304,70 @@ public void testTrailingNoreturnFunctionDefinition() throws Exception { // [[noreturn]] void foo() throw(char const *) { // throw "exception"; // } + @Test public void testLeadingNoreturnFunctionDefinition() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDefinition.class); } // void foo() throw(char const *) [[noreturn]]; + @Test public void testTrailingNoReturnFunctionDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); } // [[noreturn]] void foo() throw(char const *); + @Test public void testLeadingNoReturnFunctionDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); } // class [[attr]] C{}; + @Test public void testAttributedClass() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTCompositeTypeSpecifier.class); } // void f() { try { } catch ([[attr]] int& id) {} } + @Test public void testAttributedExceptionDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); } // struct [[attr]] S; + @Test public void testAttributedElaboratedTypeSpecifier() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTElaboratedTypeSpecifier.class); } // static int [[int_attr]] v; + @Test public void testAttributedDeclSpecifier() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTSimpleDeclSpecifier.class); } //auto [[maybe_unused]] variable; + @Test public void testAttributeAutoDeclSpecifer() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTSimpleDeclSpecifier.class); } // const volatile unsigned long int [[attr]] cvuli; + @Test public void testAttributedTypeSpecifier() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTSimpleDeclSpecifier.class); } // int * [[pointer_attribute]] * [[pointer_attribute]] ipp; + @Test public void testAttributedPtrOperators() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); List specifiers = getAttributeSpecifiers(tu); @@ -360,42 +380,49 @@ public void testAttributedPtrOperators() throws Exception { } // int & [[ref_attribute]] iRef; + @Test public void testAttributedRefOperator() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTReferenceOperator.class); } // int && [[rvalue_ref_attribute]] iRvalueRef; + @Test public void testAttributedRvalueRefOperator() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTReferenceOperator.class); } // void foo() [[function_attr]]; + @Test public void testAttributedFunctionDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); } // int ipp [[declarator_attr]]; + @Test public void testAttributedDeclarator() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTDeclarator.class); } // int iArr[5] [[arr_attr]]; + @Test public void testAttributedArrayDeclarator() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTArrayModifier.class); } // [[attr]] int i; + @Test public void testAttributedSimpleDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); } // [[attr]] void bar(){} + @Test public void testAttributedFunctionDefinition() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDefinition.class); @@ -404,6 +431,7 @@ public void testAttributedFunctionDefinition() throws Exception { // struct S { // [[ctor_attr]] S() = delete; // }; + @Test public void testDeletedCtor() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDefinition.class); @@ -412,6 +440,7 @@ public void testDeletedCtor() throws Exception { // struct S { // [[dtor_attr]] ~S() = default; // }; + @Test public void testDefaultedDtor() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDefinition.class); @@ -420,18 +449,21 @@ public void testDefaultedDtor() throws Exception { // void bar() { // [[attr]] int i; // } + @Test public void testAttributedSimpleDeclarationInStatement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); checkAttributeRelations(getAttributeSpecifiers(tu), IASTSimpleDeclaration.class); } // [[]] int i; + @Test public void testEmptyAttributeSpecifier() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(IASTAttribute.EMPTY_ATTRIBUTE_ARRAY, attributes); } // [[attr]] [[attr2]] [[attr3]] int i; + @Test public void testMultipleSequentialAttributeSpecifiers() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); List specifiers = getAttributeSpecifiers(tu); @@ -450,6 +482,7 @@ public void testMultipleSequentialAttributeSpecifiers() throws Exception { } // [[attr1, attr2]] int i; + @Test public void testMultipleAttributes() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(2, attributes.length); @@ -460,6 +493,7 @@ public void testMultipleAttributes() throws Exception { } // [[attribute ...]] int i; + @Test public void testPackExpansionAttribute() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(1, attributes.length); @@ -469,6 +503,7 @@ public void testPackExpansionAttribute() throws Exception { } // [[scope::attribute]] int i; + @Test public void testScopedAttribute() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(1, attributes.length); @@ -479,6 +514,7 @@ public void testScopedAttribute() throws Exception { } // [[attr()]] int i; + @Test public void testAttributeWithEmptyArgument() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(1, attributes.length); @@ -489,6 +525,7 @@ public void testAttributeWithEmptyArgument() throws Exception { } // [[attr(this(is){[my]}(argument[with]{some},parentheses))]] int i; + @Test public void testAttributeWithBalancedArgument() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(1, attributes.length); @@ -501,6 +538,7 @@ public void testAttributeWithBalancedArgument() throws Exception { } // [[attr(class)]] int i; + @Test public void testAttributeWithKeywordArgument() throws Exception { IASTAttribute[] attributes = getAttributes(); assertEquals(1, attributes.length); @@ -514,18 +552,21 @@ public void testAttributeWithKeywordArgument() throws Exception { } // struct S __attribute__((__packed__)) {}; + @Test public void testGCCAttributedStruct() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTCompositeTypeSpecifier.class); } // int a __attribute__ ((aligned ((64)))); + @Test public void testGCCAttributedVariableDeclarator_bug391572() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), IASTDeclarator.class); } // int a __attribute__ (()); + @Test public void testEmptyGCCAttribute() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), IASTDeclarator.class); @@ -534,6 +575,7 @@ public void testEmptyGCCAttribute() throws Exception { // struct S { // void foo() override __attribute__((attr)); // }; + @Test public void testGCCAttributeAfterOverride_bug413615() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTFunctionDeclarator.class); @@ -542,6 +584,7 @@ public void testGCCAttributeAfterOverride_bug413615() throws Exception { // enum E { // value1 [[attr1]], value2 [[attr2]] = 1 // }; + @Test public void testAttributedEnumerator_Bug535269() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), IASTEnumerator.class, IASTEnumerator.class); @@ -549,6 +592,7 @@ public void testAttributedEnumerator_Bug535269() throws Exception { //void f([[attr1]] int [[attr2]] p) { //} + @Test public void testAttributedFunctionParameter_Bug535275() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTParameterDeclaration.class, @@ -556,24 +600,28 @@ public void testAttributedFunctionParameter_Bug535275() throws Exception { } //namespace [[attr]] NS {} + @Test public void testAttributedNamedNamespace_Bug535274() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } //namespace [[attr]] {} + @Test public void testAttributedUnnamedNamespace_Bug535274() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } //namespace NS __attribute__((__visibility__("default"))) {} + @Test public void testGnuAndCppMixedAttributedNamedNamespace_Bug535274() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); checkAttributeRelations(getAttributeSpecifiers(tu), ICPPASTNamespaceDefinition.class); } // [[attr]] __attribute__((__visibility__("default"))) [[attr2]] __attribute__((__section__(".foo"))) int i; + @Test public void testMixedAttributeSpecifiers() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), ParserLanguage.CPP, ScannerKind.GNU); List specifiers = getAttributeSpecifiers(tu); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java index eb2eb4fb699..1e3f37574ac 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPImplicitNameTests.java @@ -16,6 +16,12 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + import java.io.IOException; import org.eclipse.cdt.core.dom.ast.IASTImplicitDestructorName; @@ -31,8 +37,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.parser.ParserException; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Tests for classes implementing {@link IASTImplicitNameOwner} and {@link IASTImplicitDestructorNameOwner} @@ -40,17 +45,6 @@ */ public class AST2CPPImplicitNameTests extends AST2TestBase { - public AST2CPPImplicitNameTests() { - } - - public AST2CPPImplicitNameTests(String name) { - super(name); - } - - public static TestSuite suite() { - return suite(AST2CPPImplicitNameTests.class); - } - protected BindingAssertionHelper getAssertionHelper() throws ParserException, IOException { String code = getAboveComment(); return new AST2AssertionHelper(code, ParserLanguage.CPP); @@ -103,6 +97,7 @@ protected IASTImplicitDestructorName[] getImplicitDestructorNames(IASTTranslatio // -p; // +p; // } + @Test public void testBinaryExpressions() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -147,6 +142,7 @@ public void testBinaryExpressions() throws Exception { // int* y; // *y; //2 // } + @Test public void testPointerDereference() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertImplicitName("*x;", 1, ICPPFunction.class); @@ -165,6 +161,7 @@ public void testPointerDereference() throws Exception { // X (Y::*px1) = &Y::x; // not the overloaded operator // X* px2 = &y; // overloaded // } + @Test public void testPointerToMember() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -198,6 +195,7 @@ public void testPointerToMember() throws Exception { // SecondLevelProxy p2; // p2->doA(); // } + @Test public void testArrowOperator() throws Exception { String contents = getAboveComment(); IASTTranslationUnit tu = parse(contents, ParserLanguage.CPP); @@ -226,6 +224,7 @@ public void testArrowOperator() throws Exception { // (p1++).x; //1 // (++p1).x; //2 // } + @Test public void testUnaryPrefixAndPostfix() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertImplicitName("++).x; //1", 2, ICPPFunction.class); @@ -252,6 +251,7 @@ public void testUnaryPrefixAndPostfix() throws Exception { // D d; // test(a, b, c, d); // func // } + @Test public void testCommaOperator1() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); // expression lists are used in function calls but they should not resolve to the comma operator @@ -287,6 +287,7 @@ public void testCommaOperator1() throws Exception { // int test(A a, B b, C c, D d) { // (a, b, c, d).ee; // expr // } + @Test public void testCommaOperator2() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); @@ -318,6 +319,7 @@ public void testCommaOperator2() throws Exception { // x(); // 2 // x(1, 2); // 3 // } + @Test public void testFunctionCallOperator() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -359,6 +361,7 @@ public void testFunctionCallOperator() throws Exception { // B b; // b = a; // should not resolve // } + @Test public void testCopyAssignmentOperator() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNoImplicitName("= a;", 1); @@ -377,6 +380,7 @@ public void testCopyAssignmentOperator() throws Exception { // func(x[0]); //1 // func(y[q]); //2 // } + @Test public void testArraySubscript() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -412,6 +416,7 @@ public void testArraySubscript() throws Exception { // delete[] x; // delete 1; // } + @Test public void testDelete() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitName[] names = ba.getImplicitNames("delete x;", 6); @@ -446,6 +451,7 @@ public void testDelete() throws Exception { // B* b = new B; // delete b; // } + @Test public void testOverloadedDelete_Bug351547() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IBinding m = bh.assertNonProblem("operator delete(void * a)", 15); @@ -473,6 +479,7 @@ public void testOverloadedDelete_Bug351547() throws Exception { // A *a = new A; // B* b = new B; // } + @Test public void testOverloadedNew_Bug354585() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IBinding m = bh.assertNonProblem("operator new(size_t a)", 12); @@ -492,6 +499,7 @@ public void testOverloadedNew_Bug354585() throws Exception { // X* xs = new X[5]; // delete[] x; // } + @Test public void testImplicitNewAndDelete() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNoImplicitName("new X", 3); @@ -511,6 +519,7 @@ public void testImplicitNewAndDelete() throws Exception { // int* p = new (nothrow) int[5]; // int* p2 = new (5, 6) int[5]; // } + @Test public void testNew() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitName n1 = ba.assertImplicitName("new (nothrow) X", 3, ICPPFunction.class); @@ -529,6 +538,7 @@ public void testNew() throws Exception { // int test() { // throw; // } + @Test public void testEmptyThrow() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNoImplicitName("throw;", 5); @@ -558,6 +568,7 @@ public void testEmptyThrow() throws Exception { // C(int p) : u(), v(p) {} // }; // B C::t = 1; + @Test public void testConstructorCall() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -597,6 +608,7 @@ public void testConstructorCall() throws Exception { // if (aa==b) { // } // } + @Test public void testBuiltinOperators_294543() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTTranslationUnit tu = ba.getTranslationUnit(); @@ -613,6 +625,7 @@ public void testBuiltinOperators_294543() throws Exception { // int x; // x = A().a; // } + @Test public void testTemporaryDestruction() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A().a"); @@ -628,6 +641,7 @@ public void testTemporaryDestruction() throws Exception { // A x; // x = A(); // } + @Test public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("x = A()"); @@ -641,6 +655,7 @@ public void testTemporaryNotCreatedWhenBoundToVariable() throws Exception { // int test() { // return (new A())->a; // } + @Test public void testTemporaryNotCreatesInNewExpression() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("(new A())->a"); @@ -654,6 +669,7 @@ public void testTemporaryNotCreatesInNewExpression() throws Exception { // void test() { // A& x = A(); // } + @Test public void testTemporaryBoundToReference() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("A()"); @@ -671,6 +687,7 @@ public void testTemporaryBoundToReference() throws Exception { // const S& s2 = S(1); // S s3; // }//1 + @Test public void testOrderOfDestruction() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IASTImplicitDestructorName[] names = ba.getImplicitDestructorNames("}//1", 1); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java index 63edd1505b0..ad053120184 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPSpecTest.java @@ -16,6 +16,11 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; + import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclaration; @@ -44,31 +49,21 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; /** * Examples taken from the c++-specification. */ public class AST2CPPSpecTest extends AST2SpecTestBase { - public AST2CPPSpecTest() { - } - - public AST2CPPSpecTest(String name) { - super(name); - } - - public static TestSuite suite() { - return suite(AST2CPPSpecTest.class); - } - // int x=x+++++y; + @Test public void test2_4s5() throws Exception { parseCandCPP(getAboveComment(), false, 0); } // int a=12, b=014, c=0XC; + @Test public void test2_13_1s1() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -76,6 +71,7 @@ public void test2_13_1s1() throws Exception { // ??=define arraycheck(a,b) a??(b??) ??!??! b??(a??) // // becomes // #define arraycheck(a,b) a[b] || b[a] + @Test public void test2_3s2() throws Exception { // TODO exists bug 64993 parseCandCPP(getAboveComment(), true, 0); } @@ -102,6 +98,7 @@ public void test2_3s2() throws Exception { // TODO exists bug 64993 // typedef int Int; // declares Int // extern X anotherX; // declares anotherX // using N::d; // declares N::d + @Test public void test3_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -115,6 +112,7 @@ public void test3_1s3() throws Exception { // C b = a; // b = a; // } + @Test public void test3_1s4a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -127,6 +125,7 @@ public void test3_1s4a() throws Exception { // ~C() { } // }; // + @Test public void test3_1s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -134,6 +133,7 @@ public void test3_1s4b() throws Exception { // struct X; // declare X as a struct type // struct X* x1; // use X in pointer formation // X* x2; // use X in pointer formation + @Test public void test3_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -146,6 +146,7 @@ public void test3_2s4() throws Exception { // X::X(int = 0) { } // class D: public X { }; // D d2; // X(int) called by D() + @Test public void test3_2s5_a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -159,6 +160,7 @@ public void test3_2s5_a() throws Exception { // class D: public X { }; // X(int, int) called by D(); // // D()'s implicit definition // // violates the ODR + @Test public void test3_2s5_b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -169,6 +171,7 @@ public void test3_2s5_b() throws Exception { // int i = j, j; // j = 42; // } + @Test public void test3_3s2() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -177,6 +180,7 @@ public void test3_3s2() throws Exception { // int x = 12; // { int x = x; } // } + @Test public void test3_3_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -185,6 +189,7 @@ public void test3_3_1s1() throws Exception { // const int i = 2; // { int i[i]; } // } + @Test public void test3_3_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -193,6 +198,7 @@ public void test3_3_1s2() throws Exception { // const int x = 12; // { enum { x = x }; } // } + @Test public void test3_3_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -219,6 +225,7 @@ public void test3_3_1s3() throws Exception { // } // int q(); // error: different return type // } + @Test public void test3_3_5s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -236,6 +243,7 @@ public void test3_3_5s1() throws Exception { // // 3) scope of namespace A // // 4) global scope, before the definition of A::N::f // } + @Test public void test3_4_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -243,6 +251,7 @@ public void test3_4_1s6() throws Exception { // namespace M { // class B { }; // } + @Test public void test3_4_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -265,6 +274,7 @@ public void test3_4_1s7() throws Exception { // // 4) scope of namespace M::N // // 5) scope of namespace M // // 6) global scope, before the definition of M::N::X::f + @Test public void test3_4_1s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -279,6 +289,7 @@ public void test3_4_1s8() throws Exception { // friend void A::f1(AT); // parameter type is A::AT // friend void A::f2(BT); // parameter type is B::BT // }; + @Test public void test3_4_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -293,6 +304,7 @@ public void test3_4_1s10() throws Exception { // A::n = 42; // OK // A b; // illformed: A does not name a type // } + @Test public void test3_4_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -305,6 +317,7 @@ public void test3_4_3s1() throws Exception { // int main() { // f(parm); //OK: calls NS::f // } + @Test public void test3_4_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -318,6 +331,7 @@ public void test3_4_2s2() throws Exception { // X C::arr[number]; // illformed: // // equivalent to: ::X C::arr[C::number]; // // not to: C::X C::arr[C::number]; + @Test public void test3_4_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -342,6 +356,7 @@ public void test3_4_3s3() throws Exception { // AB *p; // p->AB::~AB(); // explicitly calls the destructor for A // } + @Test public void test3_4_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -395,6 +410,7 @@ public void test3_4_3s5() throws Exception { // // S is { Y::h(int), Z::h(double) } and overload // // resolution chooses Z::h(double) // } + @Test public void test3_4_3_2s2() throws Exception { String[] problems = { "AB::x", "x", "AB::i", "i" }; parse(getAboveComment(), ParserLanguage.CPP, problems); // qualified names are counted double, so 4 @@ -428,6 +444,7 @@ public void test3_4_3_2s2() throws Exception { // { // BD::a++; //OK: S is { A::a, A::a } // } + @Test public void test3_4_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -449,6 +466,7 @@ public void test3_4_3_2s3() throws Exception { // A::b++; //OK: both A and B searched (once), S is { B::b } // B::b++; //OK: b declared directly in B, S is { B::b } // } + @Test public void test3_4_3_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -467,6 +485,7 @@ public void test3_4_3_2s4() throws Exception { // int i = C::x; // OK, A::x (of type int) // int j = C::y; // ambiguous, A::y or B::y // } + @Test public void test3_4_3_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -479,6 +498,7 @@ public void test3_4_3_2s5() throws Exception { // } // void A::f1(int) { } // illformed, // // f1 is not a member of A + @Test public void test3_4_3_2s6a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -496,6 +516,7 @@ public void test3_4_3_2s6a() throws Exception { // using namespace A; // using namespace C::D; // void B::f1(int){} // OK, defines A::B::f1(int) + @Test public void test3_4_3_2s6b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -528,6 +549,7 @@ public void test3_4_3_2s6b() throws Exception { // struct Base::Data; // error: cannot introduce a qualified type (7.1.5.3) // struct Base::Datum; // error: Datum undefined // struct Base::Data* pBase; // OK: refers to nested Data + @Test public void test3_4_4s3() throws Exception { String[] problems = { "::Glob", "Glob", "Base::Datum", "Datum" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -543,6 +565,7 @@ public void test3_4_4s3() throws Exception { // extern int i; //3: external linkage // } // } + @Test public void test3_5s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -562,6 +585,7 @@ public void test3_5s6() throws Exception { // } // void q() { // // } // some other, unrelated q + @Test public void test3_5s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -573,12 +597,14 @@ public void test3_5s7() throws Exception { // typedef A B; // extern B b; // illformed // } + @Test public void test3_5s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // int main(int argc, char* argv[]) { // // } + @Test public void test3_6_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -603,6 +629,7 @@ public void test3_6_1s2() throws Exception { // void* q = pb; // OK: pb points to valid memory // pb->f(); //undefined behavior, lifetime of *pb has ended // } + @Test public void test3_8s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -627,6 +654,7 @@ public void test3_8s5() throws Exception { // c1 = c2; // welldefined // c1.f(); //welldefined; c1 refers to a new object of type C // } + @Test public void test3_8s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -639,6 +667,7 @@ public void test3_8s7() throws Exception { // B b; // new (&b) T; // } //undefined behavior at block exit + @Test public void test3_8s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -652,6 +681,7 @@ public void test3_8s8() throws Exception { // b.~B(); // new (&b) const B; // undefined behavior // } + @Test public void test3_8s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -665,6 +695,7 @@ public void test3_8s9() throws Exception { // memcpy(&obj, buf, N); // at this point, each subobject of obj of scalar type // // holds its original value // } + @Test public void test3_9s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -676,6 +707,7 @@ public void test3_9s2() throws Exception { // memcpy(t1p, t2p, sizeof(T)); // at this point, every subobject of POD type in *t1p contains // // the same value as the corresponding subobject in *t2p // } + @Test public void test3_9s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -702,11 +734,13 @@ public void test3_9s3() throws Exception { // xp++; //OK: X is complete // arrp++; //ill-formed: UNKA can't be completed // } + @Test public void test3_9s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // int& f(); + @Test public void test3_10s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -717,6 +751,7 @@ public void test3_10s3() throws Exception { // i = ++i + 1; // the behavior is unspecified // i = i + 1; // the value of i is incremented // } + @Test public void test5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -727,6 +762,7 @@ public void test5s4() throws Exception { // { // B* bp = dynamic_cast(dp); // equivalent to B* bp = dp; // } + @Test public void test5_2_7s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -757,6 +793,7 @@ public void test5_2_7s5() throws Exception { // // cast from virtual base // E* ep1 = dynamic_cast(ap); // succeeds // } + @Test public void test5_2_7s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -771,6 +808,7 @@ public void test5_2_7s9() throws Exception { // typeid(D) == typeid(d2); // yields true // typeid(D) == typeid(const D&); // yields true // } + @Test public void test5_2_8s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -782,6 +820,7 @@ public void test5_2_8s5() throws Exception { // int foo() { // static_cast(br); // produces lvalue to the original d object // } + @Test public void test5_2_9s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -791,6 +830,7 @@ public void test5_2_9s5() throws Exception { // int foo() { // &B::i; // has type int A::* // } + @Test public void test5_3_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -798,6 +838,7 @@ public void test5_3_1s2() throws Exception { // void test() { // new (int (*[10])()); // }; + @Test public void test5_3_4s3() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0); IASTFunctionDefinition fdef = getDeclaration(tu, 0); @@ -818,6 +859,7 @@ public void test5_3_4s3() throws Exception { // new T[5]; // new (2,f) T[5]; // }; + @Test public void test5_3_4s12() throws Exception { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=236856 @@ -860,12 +902,14 @@ public void test5_3_4s12() throws Exception { // int n=2; // int x=new float[n][5]; // int y=new float[5][n]; + @Test public void test5_3_4s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // const char* strchr(const char* s, int c); // bool b = noexcept (strchr("abc", 'b')); + @Test public void test5_3_7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -878,6 +922,7 @@ public void test5_3_7() throws Exception { // return (A*)( p ); // illformed // // static_cast interpretation // } + @Test public void test5_4s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -885,6 +930,7 @@ public void test5_4s5() throws Exception { // int foo() { // (ptr_to_obj->*ptr_to_mfct)(10); // } + @Test public void test5_5s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -898,6 +944,7 @@ public void test5_5s6() throws Exception { // p <= q; // Both converted to const void * before comparison // pi <= pci; // Both converted to const int *const * before comparison // } + @Test public void test5_9s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -914,6 +961,7 @@ public void test5_9s2() throws Exception { // int (D::*pdl)() = pl; // int (D::*pdr)() = pr; // bool x = (pdl == pdr); // false + @Test public void test5_10s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -923,6 +971,7 @@ public void test5_10s2() throws Exception { // int a=0, t=1, c=2; // f(a, (t=3, t+2), c); // } + @Test public void test5_18s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -936,6 +985,7 @@ public void test5_18s2() throws Exception { // int i; // } // } + @Test public void test6_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -948,6 +998,7 @@ public void test6_4s1() throws Exception { // int x; // illformed,redeclaration of x // } // } + @Test public void test6_4s3() throws Exception { // raised bug 90618 // gcc does not report an error, either, so leave it as it is. @@ -963,6 +1014,7 @@ public void test6_4s3() throws Exception { // int i; // } // } + @Test public void test6_5s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -981,6 +1033,7 @@ public void test6_5s3() throws Exception { // i = 0; // } // } + @Test public void test6_5_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -992,6 +1045,7 @@ public void test6_5_1s2() throws Exception { // a[i] = i; // int j = i; // j = 42 // } + @Test public void test6_5_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1009,6 +1063,7 @@ public void test6_5_3s3() throws Exception { // // call for a followed by construction // // again immediately following label ly // } + @Test public void test6_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -1018,6 +1073,7 @@ public void test6_7s3() throws Exception { // static int s = foo(2*i); // recursive call - undefined // return i+1; // } + @Test public void test6_7s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1031,6 +1087,7 @@ public void test6_7s4() throws Exception { // T(f) = { 1, 2 }; // declaration // T(*g)(double(3)); // declaration // } + @Test public void test6_8s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1048,6 +1105,7 @@ public void test6_8s1() throws Exception { // T(d),e,f=3; //declaration // extern int h; // T(g)(h,2); //declaration + @Test public void test6_8s2() throws Exception { // TODO raised bug 90622 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1071,6 +1129,7 @@ public void test6_8s2() throws Exception { // TODO raised bug 90622 // // properly since it depends // // on T2 being a typename // } + @Test public void test6_8s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1078,12 +1137,14 @@ public void test6_8s3() throws Exception { // typedef char* Pc; // void f(const Pc); // void f(char* const) (not const char*) // void g(const int Pc); // void g(const int) + @Test public void test7_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // void h(unsigned Pc); // void h(unsigned int) // void k(unsigned int Pc); // void k(unsigned int) + @Test public void test7_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1091,6 +1152,7 @@ public void test7_1s3() throws Exception { // thread_local int e; // static thread_local int f; // extern thread_local int g; + @Test public void test7_1_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1119,6 +1181,7 @@ public void test7_1_1s1() throws Exception { // static int c; // error: inconsistent linkage // extern int d; // d has external linkage // static int d; // error: inconsistent linkage + @Test public void test7_1_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1132,6 +1195,7 @@ public void test7_1_1s7() throws Exception { // g(a); //error: S is incomplete // f(); //error: S is incomplete // } + @Test public void test7_1_1s8a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1140,6 +1204,7 @@ public void test7_1_1s8a() throws Exception { // mutable const int* p; // OK // mutable int* const q; // illformed // }; + @Test public void test7_1_1s8b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1147,6 +1212,7 @@ public void test7_1_1s8b() throws Exception { // typedef int MILES, *KLICKSP; // MILES distance; // extern KLICKSP metricp; + @Test public void test7_1_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1156,6 +1222,7 @@ public void test7_1_3s1() throws Exception { // typedef int I; // typedef int I; // typedef I I; + @Test public void test7_1_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1163,6 +1230,7 @@ public void test7_1_3s2() throws Exception { // class complex { // // }; // typedef int complex; // error: redefinition + @Test public void test7_1_3s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1170,6 +1238,7 @@ public void test7_1_3s3a() throws Exception { // typedef int complex; // class complex { // // }; // error: redefinition + @Test public void test7_1_3s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1181,11 +1250,13 @@ public void test7_1_3s3b() throws Exception { // typedef struct S T; // S a = T(); // OK // struct T * p; // error + @Test public void test7_1_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // typedef struct { } *ps, S; // S is the class name for linkage purposes + @Test public void test7_1_3s5a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1194,6 +1265,7 @@ public void test7_1_3s5a() throws Exception { // S(); //error: requires a return type because S is // // an ordinary member function, not a constructor // } S; + @Test public void test7_1_3s5b() throws Exception { IASTTranslationUnit tu = parseWithErrors(getAboveComment(), ParserLanguage.CPP); IASTCompositeTypeSpecifier comp = getCompositeType(tu, 0); @@ -1215,6 +1287,7 @@ public void test7_1_3s5b() throws Exception { // return x * x; // } // constexpr pixel large(4); + @Test public void test7_1_5s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1233,6 +1306,7 @@ public void test7_1_5s1() throws Exception { // int* iq = const_cast(ciq); // cast required // *iq = 4; // undefined: modifies a const object // } + @Test public void test7_1_5_1s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1256,12 +1330,14 @@ public void test7_1_5_1s5() throws Exception { // p->x.i = 99; // wellformed: mutable member can be modified // p->x.j = 99; // undefined: modifies a const member // } + @Test public void test7_1_5_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // enum { a, b, c=0 }; // enum { d, e, f=e+2 }; + @Test public void test7_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1270,6 +1346,7 @@ public void test7_2s2() throws Exception { // const int x = 12; // { enum { x = x }; } // } + @Test public void test7_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1281,6 +1358,7 @@ public void test7_2s3() throws Exception { // if (*cp == blue) // ... // return 0; // } + @Test public void test7_2s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1302,6 +1380,7 @@ public void test7_2s8() throws Exception { // f(p->left); // OK // // ... // } + @Test public void test7_2s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1314,6 +1393,7 @@ public void test7_2s10() throws Exception { // void g() { i++; } // Inner::i // } // } + @Test public void test7_3_1s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1333,6 +1413,7 @@ public void test7_3_1s5() throws Exception { // A::i++; // A::unique::i // j++; // A::unique::j // } + @Test public void test7_3_1_1s1() throws Exception { String[] problems = { "i" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -1342,6 +1423,7 @@ public void test7_3_1_1s1() throws Exception { // void f() { // // } // } + @Test public void test7_3_1_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1359,6 +1441,7 @@ public void test7_3_1_2s1() throws Exception { // namespace R { // void Q::V::g() { } // error: R doesn't enclose Q // } + @Test public void test7_3_1_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 2); } @@ -1388,6 +1471,7 @@ public void test7_3_1_2s2() throws Exception { // A::X::f(x); //error: f is not a member of A::X // A::X::Y::g(); // error: g is not a member of A::X::Y // } + @Test public void test7_3_1_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 4); } @@ -1396,6 +1480,7 @@ public void test7_3_1_2s3() throws Exception { // namespace CWVLN = Company_with_very_long_name; // namespace CWVLN = Company_with_very_long_name; // OK: duplicate // namespace CWVLN = CWVLN; + @Test public void test7_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1411,6 +1496,7 @@ public void test7_3_2s3() throws Exception { // void f(int) { f('c'); } // calls B::f(char) // void g(int) { g('c'); } // recursively calls D::g(int) // }; + @Test public void test7_3_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1424,6 +1510,7 @@ public void test7_3_3s3() throws Exception { // using B::x; // OK: x is a union member of base B // using C::g; // error: C isn't a base of D2 // }; + @Test public void test7_3_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1438,6 +1525,7 @@ public void test7_3_3s4() throws Exception { // using A::f; // illformed // using A::X; // illformed // }; + @Test public void test7_3_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1453,6 +1541,7 @@ public void test7_3_3s5() throws Exception { // using X::s; // error: X::s is a class member // // and this is not a member declaration. // } + @Test public void test7_3_3s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1470,6 +1559,7 @@ public void test7_3_3s6() throws Exception { // X::f(); //calls ::f // X::g(); //calls A::g // } + @Test public void test7_3_3s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1494,6 +1584,7 @@ public void test7_3_3s7() throws Exception { // using B::i; // using B::i; // error: double member declaration // }; + @Test public void test7_3_3s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1516,6 +1607,7 @@ public void test7_3_3s8() throws Exception { // // that is, for A::f(int) and A::f(char). // f('a'); //calls f(char) // } + @Test public void test7_3_3s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1541,6 +1633,7 @@ public void test7_3_3s9() throws Exception { // p->g(1); //calls B::g(int) // p->g('a'); //calls D::g(char) // } + @Test public void test7_3_3s12() throws Exception { // raised bug 161562 for that parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1571,6 +1664,7 @@ public void test7_3_3s12() throws Exception { // raised bug 161562 for that // x = 99; // assigns to A::x // struct x x1; // x1 has class type B::x // } + @Test public void test7_3_3s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1593,6 +1687,7 @@ public void test7_3_3s10() throws Exception { // void f(int); // error: // // f(int) conflicts with C::f(int) and B::f(int) // } + @Test public void test7_3_3s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1611,6 +1706,7 @@ public void test7_3_3s11() throws Exception { // return d> // x(); // ambiguous: B::x or C::x // } + @Test public void test7_3_3s14() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1628,6 +1724,7 @@ public void test7_3_3s14() throws Exception { // public: // using A::g; // B::g is a public synonym for A::g // }; + @Test public void test7_3_3s15() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1657,6 +1754,7 @@ public void test7_3_3s15() throws Exception { // void f4() { // i = 5; // illformed; neither i is visible // } + @Test public void test7_3_4s1() throws Exception { String[] problems = { "i", "i" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -1674,6 +1772,7 @@ public void test7_3_4s1() throws Exception { // using namespace N; // i = 7; // error: both M::i and N::i are visible // } + @Test public void test7_3_4s2a() throws Exception { String[] problems = { "i" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -1699,6 +1798,7 @@ public void test7_3_4s2a() throws Exception { // int n = j; // D::j hides B::j // } // } + @Test public void test7_3_4s2b() throws Exception { String[] problems = { "k" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -1729,6 +1829,7 @@ public void test7_3_4s2b() throws Exception { // f(1); //error: ambiguous: D::f(int) or E::f(int)? // f('a'); //OK: D::f(char) // } + @Test public void test7_3_4s5() throws Exception { String[] problems = { "d1", "f" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -1738,6 +1839,7 @@ public void test7_3_4s5() throws Exception { // extern "C" { // double sqrt(double); // C linkage // } + @Test public void test7_5s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -1753,6 +1855,7 @@ public void test7_5s3() throws Exception { // void (*pf2)(FUNC*); // the name of the variable pf2 has C++ linkage and // // the type of pf2 is pointer to C++ function that // // takes one parameter of type pointer to C function + @Test public void test7_5s4a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1777,6 +1880,7 @@ public void test7_5s4a() throws Exception { // // C function // }; // } + @Test public void test7_5s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1800,12 +1904,14 @@ public void test7_5s4b() throws Exception { // // definition for the function h // // with C language linkage // // A::h and ::h refer to the same function + @Test public void test7_5s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // extern "C" double f(); // static double f(); // error + @Test public void test7_5s7a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1814,11 +1920,13 @@ public void test7_5s7a() throws Exception { // extern "C" { // int i; // definition // } + @Test public void test7_5s7b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // extern "C" static void f(); // error + @Test public void test7_5s7c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1829,6 +1937,7 @@ public void test7_5s7c() throws Exception { // int (*p3i)[3]; // int *f(); // int (*pf)(double); + @Test public void test8_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1843,6 +1952,7 @@ public void test8_1s1() throws Exception { // S y((int)a); // object declaration // S z = int(a); // object declaration // } + @Test public void test8_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1853,6 +1963,7 @@ public void test8_2s1() throws Exception { // }; // S x; // typeid // S y; // expression (illformed) + @Test public void test8_2s4() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 1); NameCollector col = new NameCollector(); @@ -1872,6 +1983,7 @@ public void test8_2s4() throws Exception { // sizeof(int(1)); // expression // // sizeof(int()); // typeid (illformed) // } + @Test public void test8_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1881,6 +1993,7 @@ public void test8_2s5() throws Exception { // (int(1)); //expression // // (int())1; //typeid (illformed) // } + @Test public void test8_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1893,6 +2006,7 @@ public void test8_2s6() throws Exception { // f(1); //error: cannot convert 1 to function pointer // f(g); //OK // } + @Test public void test8_2s7a() throws Exception { // TODO raised bug 90633 final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 1); @@ -1905,6 +2019,7 @@ public void test8_2s7a() throws Exception { // TODO raised bug 90633 // class C { }; // void h(int *(C[10])); // void h(int *(*_fp)(C _parm[10])); // // not: void h(int *C[10]); + @Test public void test8_2s7b() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 0); @@ -1920,11 +2035,13 @@ public void test8_2s7b() throws Exception { // void A::B::f() { } // illformed: the declarator must not be // // qualified with A:: // } + @Test public void test8_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // int unsigned i; + @Test public void test8_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1940,6 +2057,7 @@ public void test8_3s4() throws Exception { // pc = p; // ppc = &pc; // } + @Test public void test8_3_1s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1955,6 +2073,7 @@ public void test8_3_1s2a() throws Exception { // p = pc; // error // ppc = &p; // error // } + @Test public void test8_3_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1965,6 +2084,7 @@ public void test8_3_1s2b() throws Exception { // *ppc = &ci; // OK, but would make p point to ci ... // *p = 5; // clobber ci // } + @Test public void test8_3_1s2c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -1972,6 +2092,7 @@ public void test8_3_1s2c() throws Exception { // typedef int& A; // const A aref = 3; // illformed; // // nonconst reference initialized with rvalue + @Test public void test8_3_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2003,6 +2124,7 @@ public void test8_3_2s1() throws Exception { // link* q = new link; // h(q); // } + @Test public void test8_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2026,6 +2148,7 @@ public void test8_3_2s3() throws Exception { // (obj.*pmf)(7); //call a function member of obj // // with the argument 7 // } + @Test public void test8_3_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2033,17 +2156,20 @@ public void test8_3_3s2() throws Exception { // typedef int A[5], AA[2][3]; // typedef const A CA; // type is ''array of 5 const int'' // typedef const AA CAA; // type is ''array of 2 array of 3 const int'' + @Test public void test8_3_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // float fa[17], *afp[17]; // static int x3d[3][5][7]; + @Test public void test8_3_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // int x[3][5]; + @Test public void test8_3_4s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2054,6 +2180,7 @@ public void test8_3_4s8() throws Exception { // printf("hello world"); // printf("a=%d b=%d", a, b); // } + @Test public void test8_3_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2063,12 +2190,14 @@ public void test8_3_5s2() throws Exception { // const F f; // illformed: // // not equivalent to: void f() const; // }; + @Test public void test8_3_5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // #define FILE int // int fseek(FILE*, long, int); + @Test public void test8_3_5s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2077,6 +2206,7 @@ public void test8_3_5s5() throws Exception { // F fv; // OK: equivalent to void fv(); // // F fv { } // illformed // void fv() { } // OK: definition of fv + @Test public void test8_3_5s7a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2088,6 +2218,7 @@ public void test8_3_5s7a() throws Exception { // FIC f; // OK // }; // FIC S::*pm = &S::f; // OK + @Test public void test8_3_5s7b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2098,12 +2229,14 @@ public void test8_3_5s7b() throws Exception { // *fpi(int), // (*pif)(const char*, const char*), // (*fpif(int))(int); + @Test public void test8_3_5s9a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // typedef int IFUNC(int); // IFUNC* fpif(int); + @Test public void test8_3_5s9b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2112,6 +2245,7 @@ public void test8_3_5s9b() throws Exception { // void f() { // point(1,2); point(1); point(); // } + @Test public void test8_3_6s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2137,6 +2271,7 @@ public void test8_3_6s2() throws Exception { // { // f(6); //OK, calls f(6, 7) // } + @Test public void test8_3_6s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2151,6 +2286,7 @@ public void test8_3_6s4() throws Exception { // g(); // g(f(::a)) // } // } + @Test public void test8_3_6s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2163,6 +2299,7 @@ public void test8_3_6s5() throws Exception { // { } // specified in class scope // void C::g(int i = 88, int j) // in this translation unit, // { } + @Test public void test8_3_6s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2173,6 +2310,7 @@ public void test8_3_6s6() throws Exception { // extern void g(int x = i); // error // // ... // } + @Test public void test8_3_6s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2180,6 +2318,7 @@ public void test8_3_6s7() throws Exception { // class A { // void f(A* p = this) { } // error // }; + @Test public void test8_3_6s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2190,6 +2329,7 @@ public void test8_3_6s8() throws Exception { // typedef int I; // int g(float I, int b = I(2)); // error: parameter I found // int h(int a, int b = sizeof(a)); // error, parameter a used + @Test public void test8_3_6s9a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2202,6 +2342,7 @@ public void test8_3_6s9a() throws Exception { // int mem2(int i = b); // OK; use X::b // static int b; // }; + @Test public void test8_3_6s9b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2214,6 +2355,7 @@ public void test8_3_6s9b() throws Exception { // } // int (*p1)(int) = &f; // int (*p2)() = &f; // error: type mismatch + @Test public void test8_3_6s9c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2231,6 +2373,7 @@ public void test8_3_6s9c() throws Exception { // pa->f(); //OK, calls pa->B::f(7) // pb->f(); //error: wrong number of arguments for B::f() // } + @Test public void test8_3_6s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2240,6 +2383,7 @@ public void test8_3_6s10() throws Exception { // int m = (a > b) ? a : b; // return (m > c) ? m : c; // } + @Test public void test8_4s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2257,6 +2401,7 @@ public void test8_4s2() throws Exception { // void g() volatile const& {} // void h() volatile const&& {} //}; + @Test public void test8s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2265,6 +2410,7 @@ public void test8s4() throws Exception { // { // //printf("a = %d",a); // } + @Test public void test8_4s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2276,6 +2422,7 @@ public void test8_4s5() throws Exception { // }; // int X::a = 1; // int X::b = a; // X::b = X::a + @Test public void test8_5s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2287,11 +2434,13 @@ public void test8_5s10() throws Exception { // int j; // } b; // } a = { 1, { 2, 3 } }; + @Test public void test8_5_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // int x[] = { 1, 3, 5 }; + @Test public void test8_5_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2301,17 +2450,20 @@ public void test8_5_1s4() throws Exception { // static int s; // int j; // } a = { 1, 2 }; + @Test public void test8_5_1s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // char cv[4] = { 'a', 's', 'd', 'f', 0 }; // error + @Test public void test8_5_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // struct S { int a; char* b; int c; }; // S ss = { 1, "asdf" }; + @Test public void test8_5_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2321,6 +2473,7 @@ public void test8_5_1s7() throws Exception { // S s; // int i; // } a = { { } , 3 }; + @Test public void test8_5_1s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2329,6 +2482,7 @@ public void test8_5_1s8() throws Exception { // float y[4][3] = { // { 1 }, { 2 }, { 3 }, { 4 } // }; + @Test public void test8_5_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2338,6 +2492,7 @@ public void test8_5_1s10() throws Exception { // { 2, 4, 6 }, // { 3, 5, 7 }, // }; + @Test public void test8_5_1s11a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2345,6 +2500,7 @@ public void test8_5_1s11a() throws Exception { // float y[4][3] = { // 1, 3, 5, 2, 4, 6, 3, 5, 7 // }; + @Test public void test8_5_1s11b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2359,6 +2515,7 @@ public void test8_5_1s11b() throws Exception { // }; // A a; // B b = { 4, a, a }; + @Test public void test8_5_1s12() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2369,17 +2526,20 @@ public void test8_5_1s12() throws Exception { // u c = 1; // error // u d = { 0, "asdf" }; // error // u e = { "asdf" }; // error + @Test public void test8_5_1s15() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // char msg[] = "Syntax error on line %s"; + @Test public void test8_5_2s1() throws Exception { // raised bug 90647 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // char cv[4] = "asdf"; // error + @Test public void test8_5_2s2() throws Exception { // we do not check the size of an array, which is ok. parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -2387,6 +2547,7 @@ public void test8_5_2s2() throws Exception { // int& r1; // error: initializer missing // extern int& r2; // OK + @Test public void test8_5_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2414,6 +2575,7 @@ public void test8_5_3s2() throws Exception { // f5(b); // f6(B()); // } + @Test public void test8_5_3s5a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2425,6 +2587,7 @@ public void test8_5_3s5a() throws Exception { // int i = 2; // f2(i); // error: type mismatch and reference not const // } + @Test public void test8_5_3s5b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(ParserLanguage.CPP); helper.assertProblem("f1(2", "f1"); @@ -2450,6 +2613,7 @@ public void test8_5_3s5b() throws Exception { // f4(x); // bound directly to the result of operator B // f3(X()); // error: lvalue-to-rvalue conversion applied to result of operator int& // } + @Test public void test8_5_3s5c() throws Exception { BindingAssertionHelper helper = getAssertionHelper(ParserLanguage.CPP); helper.assertNonProblem("f1(f", "f1"); @@ -2473,6 +2637,7 @@ public void test8_5_3s5c() throws Exception { // f2(d); // error: copying lvalue of related type // f2(i); // } + @Test public void test8_5_3s5d() throws Exception { BindingAssertionHelper helper = getAssertionHelper(ParserLanguage.CPP); helper.assertNonProblem("f1(2", "f1"); @@ -2495,6 +2660,7 @@ public void test8_5_3s5d() throws Exception { // int f(Y); // struct S { int a; }; // struct S { int a; }; // error, double definition + @Test public void test9_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2513,6 +2679,7 @@ public void test9_1s1() throws Exception { // stat(ps); //call stat() // // ... // } + @Test public void test9_1s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2526,6 +2693,7 @@ public void test9_1s2a() throws Exception { // struct s { char* p; }; // define local struct s // struct s; // redeclaration, has no effect // } + @Test public void test9_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2539,6 +2707,7 @@ public void test9_1s2b() throws Exception { // // ... // friend Vector operator*(Matrix&, Vector&); // }; + @Test public void test9_1s2c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2549,11 +2718,13 @@ public void test9_1s2c() throws Exception { // struct s* p = new struct s; // global s // p->a = s; // local s // } + @Test public void test9_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // class A * A; + @Test public void test9_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2565,6 +2736,7 @@ public void test9_1s4() throws Exception { // tnode *right; // }; // tnode s, *sp; + @Test public void test9_2s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2575,6 +2747,7 @@ public void test9_2s11() throws Exception { // void f(T); // }; // void X::f(T t = count) { } + @Test public void test9_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2589,6 +2762,7 @@ public void test9_3s5() throws Exception { // fv S::* pmfv1 = &S::memfunc1; // fv S::* pmfv2 = &S::memfunc2; // fvc S::* pmfv3 = &S::memfunc3; + @Test public void test9_3s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2614,6 +2788,7 @@ public void test9_3s9() throws Exception { // n1.set("abc",&n2,0); // n2.set("def",0,0); // } + @Test public void test9_3_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2622,6 +2797,7 @@ public void test9_3_1s2() throws Exception { // void g() const; // void h() const volatile; // }; + @Test public void test9_3_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2633,6 +2809,7 @@ public void test9_3_1s3() throws Exception { // int h() const { return a++; } // error // }; // int s::f() const { return a; } + @Test public void test9_3_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2651,6 +2828,7 @@ public void test9_3_2s2() throws Exception { // y.f(); // y.g(); //error // } + @Test public void test9_3_2s4() throws Exception { String[] problems = { "g" }; final String code = getAboveComment(); @@ -2670,6 +2848,7 @@ public void test9_3_2s4() throws Exception { // process::reschedule(); // OK: no object necessary // g().reschedule(); // g() is called // } + @Test public void test9_4s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2682,6 +2861,7 @@ public void test9_4s2a() throws Exception { // static int i; // }; // int Y::i = g(); // equivalent to Y::g(); + @Test public void test9_4s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2692,6 +2872,7 @@ public void test9_4s2b() throws Exception { // }; // process* process::running = get_main(); // process* process::run_chain = running; + @Test public void test9_4_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2704,6 +2885,7 @@ public void test9_4_2s2() throws Exception { // p = "Jennifer"; // // ... // } + @Test public void test9_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2713,6 +2895,7 @@ public void test9_5s2() throws Exception { // aa = 1; // error // ptr->aa = 1; // OK // } + @Test public void test9_5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2727,6 +2910,7 @@ public void test9_5s4() throws Exception { // if (a.b == t) // shall yield true // { } // } + @Test public void test9_6s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2754,6 +2938,7 @@ public void test9_6s4() throws Exception { // }; // }; // inner* p = 0; // error: inner not in scope + @Test public void test9_7s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2767,6 +2952,7 @@ public void test9_7s1() throws Exception { // }; // int enclose::inner::x = 1; // void enclose::inner::f(int i) { } + @Test public void test9_7s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2777,6 +2963,7 @@ public void test9_7s2() throws Exception { // class I1 {}; // definition of nested class // }; // class E::I2 {}; // definition of nested class + @Test public void test9_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2796,6 +2983,7 @@ public void test9_7s3() throws Exception { // // ... // } // local* p = 0; // error: local not in scope + @Test public void test9_8s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2810,6 +2998,7 @@ public void test9_8s1() throws Exception { // Y c; // error // X::Y d; // OK // X::I e; // OK + @Test public void test9_9s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2826,6 +3015,7 @@ public void test9_9s1() throws Exception { // public: // int c; // }; + @Test public void test10s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2834,12 +3024,14 @@ public void test10s2() throws Exception { // class B { }; // class C { }; // class D : public A, public B, public C { }; + @Test public void test10_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // class X { }; // class Y : public X, public X { }; // illformed + @Test public void test10_1s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2850,6 +3042,7 @@ public void test10_1s3a() throws Exception { // class C : public A, public B { void f(); }; // wellformed // class D : public A, public L { void f(); }; // wellformed // + @Test public void test10_1s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2883,6 +3076,7 @@ public void test10_1s3b() throws Exception { // pc->h(); //OK // pc->h(1); //OK // } + @Test public void test10_2s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2895,6 +3089,7 @@ public void test10_2s3a() throws Exception { // i; //finds U::i in two ways: as W::i and U::i in V // // no ambiguity because U::i is static // } + @Test public void test10_2s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2910,6 +3105,7 @@ public void test10_2s3b() throws Exception { // class C : public A, public B { // int f() { return A::f() + B::f(); } // }; + @Test public void test10_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2932,6 +3128,7 @@ public void test10_2s4() throws Exception { // e; // OK: only one e (enumerator) // pd->a++; //error, ambiguous: two as in D // } + @Test public void test10_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -2946,6 +3143,7 @@ public void test10_2s5() throws Exception { // }; // class C : public virtual V, public W { }; // class D : public B, public C { void glorp(); }; + @Test public void test10_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2962,6 +3160,7 @@ public void test10_2s6() throws Exception { // A* pa = &d; // error, ambiguous: C's A or B's A? // V* pv = &d; // OK: only one V subobject // } + @Test public void test10_2s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -2980,6 +3179,7 @@ public void test10_2s7() throws Exception { // c.f(); //calls B::f, the final overrider // c.C::f(); //calls A::f because of the usingdeclaration // } + @Test public void test10_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3021,6 +3221,7 @@ public void test10_3s2() throws Exception { // // convert the result to B* // dp->vf2(); //illformed: argument mismatch // } + @Test public void test10_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3046,6 +3247,7 @@ public void test10_3s5() throws Exception { // ap->f(); //calls D::B1::f // dp->f(); //illformed: ambiguous // } + @Test public void test10_3s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3064,6 +3266,7 @@ public void test10_3s9() throws Exception { // struct Okay : VB1, VB2 { // void f(); // }; + @Test public void test10_3s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3077,6 +3280,7 @@ public void test10_3s10() throws Exception { // VB1a* vb1ap = new Da; // vb1ap->f(); //calls VB2::f // } + @Test public void test10_3s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3084,6 +3288,7 @@ public void test10_3s11() throws Exception { // class B { public: virtual void f(); }; // class D : public B { public: void f(); }; // void D::f() { B::f(); } + @Test public void test10_3s12() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3099,6 +3304,7 @@ public void test10_3s12() throws Exception { // virtual void draw() = 0; // pure virtual // // ... // }; + @Test public void test10_4s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3117,6 +3323,7 @@ public void test10_4s2a() throws Exception { // shape f(); // error // void g(shape); // error // shape& h(shape&); // OK + @Test public void test10_4s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3127,6 +3334,7 @@ public void test10_4s3() throws Exception { // void rotate(int) {} // // ab_circle::draw() is a pure virtual // }; + @Test public void test10_4s4a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3137,6 +3345,7 @@ public void test10_4s4a() throws Exception { // void rotate(int) {} // void draw(); // a definition is required somewhere // }; + @Test public void test10_4s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3147,6 +3356,7 @@ public void test10_4s4b() throws Exception { // struct S { // int a; // S::a is public by default // }; + @Test public void test11s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3162,6 +3372,7 @@ public void test11s2() throws Exception { // A::BB x; // OK, typedef name A::BB is public // A::B y; // access error, A::B is private // } + @Test public void test11s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3176,6 +3387,7 @@ public void test11s3() throws Exception { // A::I g(A::I p = A::x); // A::I g(A::I p) { return 0; } // A::I A::x = 0; + @Test public void test11s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3186,6 +3398,7 @@ public void test11s5() throws Exception { // }; // }; // int D::E::m = 1; // OK, no access error on private E + @Test public void test11s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3196,6 +3409,7 @@ public void test11s6() throws Exception { // int b; // X::b is public // int c; // X::c is public // }; + @Test public void test11_1s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3209,6 +3423,7 @@ public void test11_1s1a() throws Exception { // public: // int d; // S::d is public // }; + @Test public void test11s1b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3218,6 +3433,7 @@ public void test11s1b() throws Exception { // private: // class A { }; // error: cannot change access // }; + @Test public void test11_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3231,6 +3447,7 @@ public void test11_1s3() throws Exception { // struct D6 : B { }; // B public by default // class D7 : protected B { }; // struct D8 : protected B { }; + @Test public void test11_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3256,6 +3473,7 @@ public void test11_2s2() throws Exception { // B* bp2 = (B*)this; // OK with cast // bp2->mi = 3; // OK: access through a pointer to B. // } + @Test public void test11_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3271,6 +3489,7 @@ public void test11_2s3() throws Exception { // p->i = 1; // OK: B* can be implicitly cast to A*, // // and f has access to i in A // } + @Test public void test11_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3289,6 +3508,7 @@ public void test11_2s4() throws Exception { // friend_set(&obj,10); // obj.member_set(10); // } + @Test public void test11_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3306,6 +3526,7 @@ public void test11_4s1() throws Exception { // // to declare members of nested class of X // }; // }; + @Test public void test11_4s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3320,6 +3541,7 @@ public void test11_4s2a() throws Exception { // class Z { // int v[X::a]; // error: X::a is private // }; + @Test public void test11_4s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3328,6 +3550,7 @@ public void test11_4s2b() throws Exception { // friend char* X::foo(int); // // ... // }; + @Test public void test11_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3336,6 +3559,7 @@ public void test11_4s4() throws Exception { // friend void f() { } // definition of global f, a friend of M, // // not the definition of a member function // }; + @Test public void test11_4s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3361,6 +3585,7 @@ public void test11_4s5() throws Exception { // // despite being derived from a friend // } // }; + @Test public void test11_4s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3381,6 +3606,7 @@ public void test11_4s8() throws Exception { // X *px; // OK, but ::X is found // Z *pz; // error, no Z is found // } + @Test public void test11_4s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3425,6 +3651,7 @@ public void test11_4s9() throws Exception { // p1->i = 2; // illformed // p2->i = 3; // illformed // } + @Test public void test11_5s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3446,6 +3673,7 @@ public void test11_5s1() throws Exception { // // D::f() is invoked // pd->f(); //error: D::f() is private // } + @Test public void test11_6s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3456,6 +3684,7 @@ public void test11_6s1() throws Exception { // class C : public A, public B { // void f() { W::f(); } // OK // }; + @Test public void test11_7s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3476,6 +3705,7 @@ public void test11_7s1() throws Exception { // return p->y; // error: I::y is private // } // }; + @Test public void test11_8s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3491,6 +3721,7 @@ public void test11_8s1() throws Exception { // C::B *t; // error, C::B is inaccessible // }; // }; + @Test public void test11_8s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3500,6 +3731,7 @@ public void test11_8s2() throws Exception { // C(); //declares the constructor // }; // C::C() { } // defines the constructor + @Test public void test12_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3518,6 +3750,7 @@ public void test12_1s1() throws Exception { // << '\ // '; // } + @Test public void test12_1s15() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3537,6 +3770,7 @@ public void test12_1s15() throws Exception { // X b = f(X(2)); // a = f(a); // } + @Test public void test12_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3552,6 +3786,7 @@ public void test12_2s2() throws Exception { // C obj1; // const C& cr = C(16)+C(23); // C obj2; + @Test public void test12_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3570,6 +3805,7 @@ public void test12_2s5() throws Exception { // int b = a; // error: // // a.operator X().operator int() not tried // int c = X(a); // OK: a.operator X().operator int() + @Test public void test12_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3591,6 +3827,7 @@ public void test12_3s4() throws Exception { // // ... // } // } + @Test public void test12_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3608,6 +3845,7 @@ public void test12_3s5() throws Exception { // a = 2; // a = X(2) // f(3); // f(X(3)) // } + @Test public void test12_3_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3625,6 +3863,7 @@ public void test12_3_1s1() throws Exception { // Z* p = new Z(1); // OK: direct initialization syntax used // Z a4 = (Z)1; // OK: explicit cast used // Z a5 = static_cast(1); // OK: explicit cast used + @Test public void test12_3_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3640,6 +3879,7 @@ public void test12_3_1s2() throws Exception { // i = (int)a; // i = a; // } + @Test public void test12_3_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3651,6 +3891,7 @@ public void test12_3_2s2() throws Exception { // if (a) { // ... // } // } + @Test public void test12_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3671,6 +3912,7 @@ public void test12_3_2s3() throws Exception { // B_ptr->B_alias::~B(); //4 // calls B's destructor // B_ptr->B_alias::~B_alias(); //5 // calls B's destructor // } + @Test public void test12_4s12() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, false, 0); @@ -3703,6 +3945,7 @@ public void test12_4s12() throws Exception { // f(p); // p->X::~X(); //cleanup // } + @Test public void test12_4s13() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3720,6 +3963,7 @@ public void test12_4s13() throws Exception { // new D1[i]; // calls ::operator new[](size_t) // new D1; // illformed: ::operator new(size_t) hidden // } + @Test public void test12_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3734,6 +3978,7 @@ public void test12_5s2() throws Exception { // void operator delete(void*, size_t); // void operator delete[](void*); // }; + @Test public void test12_5s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3763,6 +4008,7 @@ public void test12_5s6() throws Exception { // // copy it into f // complex g = { 1, 2 }; // error; constructor is required // } + @Test public void test12_6_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3782,6 +4028,7 @@ public void test12_6_1s1() throws Exception { // float f; // complex c; // } x = { 99, 88.8, 77.7 }; + @Test public void test12_6_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3791,6 +4038,7 @@ public void test12_6_1s2() throws Exception { // struct B { }; // struct C: public A, public B { C(); }; // C::C(): global_A() { } // meminitializer for base A + @Test public void test12_6_2s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3799,6 +4047,7 @@ public void test12_6_2s2a() throws Exception { // struct B: public virtual A { }; // struct C: public A, public B { C(); }; // C::C(): A() { } // illformed: which A? + @Test public void test12_6_2s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -3813,6 +4062,7 @@ public void test12_6_2s2b() throws Exception { // D::D(int a) : B2(a+1), B1(a+2), c(a+3), b(a+4) // { } // D d(10); + @Test public void test12_6_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3848,6 +4098,7 @@ public void test12_6_2s3() throws Exception { // A a(2); // use V(int) // B b(3); // use V() // C c(4); // use V() + @Test public void test12_6_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3861,6 +4112,7 @@ public void test12_6_2s6() throws Exception { // const int& r; // X(int i): r(a), b(i), i(i), j(this->i) {} // }; + @Test public void test12_6_2s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3888,6 +4140,7 @@ public void test12_6_2s7() throws Exception { // // but base C not yet initialized // i(f()) {} // welldefined: bases are all initialized // }; + @Test public void test12_6_2s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3905,6 +4158,7 @@ public void test12_6_2s8() throws Exception { // extern X xobj; // int* p3 = &xobj.i; // OK, X is a POD class // X xobj; + @Test public void test12_7s1_a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3917,6 +4171,7 @@ public void test12_7s1_a() throws Exception { // Y() : p(&x.j) // undefined, x is not yet constructed // { } // }; + @Test public void test12_7s1_b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3947,6 +4202,7 @@ public void test12_7s1_b() throws Exception { // v->g(); // v is base of B, the call is welldefined, calls B::g // a->f(); //undefined behavior, a's type not a base of B // } + @Test public void test12_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3974,6 +4230,7 @@ public void test12_7s3() throws Exception { // dynamic_cast(a); // undefined behavior, // // a has type A*, A not a base of B // } + @Test public void test12_7s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3987,6 +4244,7 @@ public void test12_7s6() throws Exception { // X a(1); // calls X(int); // X b(a, 0); // calls X(const X&, int); // X c = b; // calls X(const X&, int); + @Test public void test12_8s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -3997,6 +4255,7 @@ public void test12_8s2a() throws Exception { // X(const X&); // X(X&); //OK // }; + @Test public void test12_8s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4007,6 +4266,7 @@ public void test12_8s2b() throws Exception { // }; // const X cx; // X x = cx; // error - X::X(X&) cannot copy cx into x + @Test public void test12_8s2c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4018,6 +4278,7 @@ public void test12_8s2c() throws Exception { // void g() { // S a( f() ); // does not instantiate member template // } + @Test public void test12_8s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4026,6 +4287,7 @@ public void test12_8s3() throws Exception { // void h(int (*)()); // redeclaration of h(int()) // void h(int x()) { } // definition of h(int()) // void h(int (*x)()) { } // illformed: redefinition of h(int()) + @Test public void test12_8s3d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4033,6 +4295,7 @@ public void test12_8s3d() throws Exception { // struct X { // X(const X&, int); // }; + @Test public void test12_8s4a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4041,6 +4304,7 @@ public void test12_8s4a() throws Exception { // X(const X&, int); // }; // X::X(const X& x, int i =0) { } + @Test public void test12_8s4b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4055,6 +4319,7 @@ public void test12_8s4b() throws Exception { // x = cx; // error: // // X::operator=(X&) cannot assign cx into x // } + @Test public void test12_8s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4063,6 +4328,7 @@ public void test12_8s9() throws Exception { // struct A : virtual V { }; // struct B : virtual V { }; // struct C : B, A { }; + @Test public void test12_8s13() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4080,6 +4346,7 @@ public void test12_8s13() throws Exception { // return t; // } // Thing t2 = f(); + @Test public void test12_8s15() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4090,6 +4357,7 @@ public void test12_8s15() throws Exception { // abs(1); //call abs(int); // abs(1.0); //call abs(double); // } + @Test public void test13s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4103,6 +4371,7 @@ public void test13s2() throws Exception { // void g() const; // OK: no static g // void g() const volatile; // OK: no static g // }; + @Test public void test12_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4112,6 +4381,7 @@ public void test12_1s2() throws Exception { // void f(Int i); // OK: redeclaration of f(int) // void f(int i) { } // void f(Int i) { } // error: redefinition of f(int) + @Test public void test12_1s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4119,6 +4389,7 @@ public void test12_1s3a() throws Exception { // enum E { a }; // void f(int i) { } // void f(E i) { } + @Test public void test12_1s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4131,6 +4402,7 @@ public void test12_1s3b() throws Exception { // int g(char[5][10]); // same as g(char(*)[10]); // int g(char[7][10]); // same as g(char(*)[10]); // int g(char(*)[20]); // different from g(char(*)[10]); + @Test public void test12_1s3c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4140,6 +4412,7 @@ public void test12_1s3c() throws Exception { // int f (const int); // redeclaration of f(int) // int f (int) { } // definition of f(int) // int f (cInt) { } // error: redefinition of f(int) + @Test public void test12_8s3e() throws Exception { String[] problems = { "f" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -4155,6 +4428,7 @@ public void test12_8s3e() throws Exception { // f (1); // OK: call f(int, int) // f (); // Error: f(int, int) or f()? // } + @Test public void test12_8s3f() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4167,6 +4441,7 @@ public void test12_8s3f() throws Exception { // public: // int f(char*); // }; + @Test public void test13_2s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4186,6 +4461,7 @@ public void test13_2s1a() throws Exception { // pd->B::f(1); //OK // pd->f("Ben"); //OK, calls D::f // } + @Test public void test13_2s1b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4205,6 +4481,7 @@ public void test13_2s1b() throws Exception { // callee(88, 99); // error: only callee(int) in scope // } // } + @Test public void test13_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4220,6 +4497,7 @@ public void test13_2s2() throws Exception { // buffer(int s) { p = new char[size = s]; } // // ... // }; + @Test public void test13_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4235,6 +4513,7 @@ public void test13_2s3() throws Exception { // // ... // }; // T a = 1; // illformed: T(C(1)) not tried + @Test public void test13_3_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4249,6 +4528,7 @@ public void test13_3_1s6() throws Exception { // } a; // int i = a(1); // Calls f1 via pointer returned from // // conversion function + @Test public void test13_3_1_1_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4268,6 +4548,7 @@ public void test13_3_1_1_2s4() throws Exception { // // user defined types exist which // // would perform the operation. // } + @Test public void test13_3_1_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4280,6 +4561,7 @@ public void test13_3_1_2s1() throws Exception { // A a, b; // a + b; // operator+(a,b) chosen over int(a) + int(b) // } + @Test public void test13_3_1_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4294,6 +4576,7 @@ public void test13_3_1_2s6() throws Exception { // // a conversion to int // float x = a; // ambiguous: both possibilities require conversions, // // and neither is better than the other + @Test public void test13_3_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4313,6 +4596,7 @@ public void test13_3_3s1() throws Exception { // // &i -> int* is better than &i -> const int* // // and c -> int is better than c -> short // } + @Test public void test13_3_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4326,6 +4610,7 @@ public void test13_3_3s3() throws Exception { // B b; // f(b); //ambiguous because b -> C via constructor and // // b -> A via constructor or conversion function. + @Test public void test13_3_3_1_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4336,6 +4621,7 @@ public void test13_3_3_1_1s2() throws Exception { // int f(B&); // int i = f(b); // Calls f(B&), an exact match, rather than // // f(A&), a conversion + @Test public void test13_3_3_1_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4344,6 +4630,7 @@ public void test13_3_3_1_4s1() throws Exception { // int f(int *); // int i; // int j = f(&i); // Calls f(int *) + @Test public void test13_3_3_2s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4365,6 +4652,7 @@ public void test13_3_3_2s3a() throws Exception { // a.f(); //CallsX::f() const // b.f(); //Calls X::f() // } + @Test public void test13_3_3_2s3b() throws Exception { String[] problems = { "g" }; parse(getAboveComment(), ParserLanguage.CPP, problems); @@ -4377,6 +4665,7 @@ public void test13_3_3_2s3b() throws Exception { // int f(float); // int i = f(a); // Calls f(int), because short -> int is // // better than short -> float. + @Test public void test13_3_3_2s3c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4388,6 +4677,7 @@ public void test13_3_3_2s3c() throws Exception { // int f(A *); // int f(B *); // int i = f(pc); // Calls f(B *) + @Test public void test13_3_3_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4401,6 +4691,7 @@ public void test13_3_3_2s4() throws Exception { // int (*p3)(long) = &X::f; // OK // int (X::*p4)(long) = &X::f; // error: mismatch // int (*p6)(long) = &(X::f); // OK + @Test public void test13_4s5b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4414,6 +4705,7 @@ public void test13_4s5b() throws Exception { // complex z = a.operator+(b); // complex z = a+b; // void* p = operator new(sizeof(int)*n); // } + @Test public void test13_5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4437,6 +4729,7 @@ public void test13_5s4() throws Exception { // dobj1 = dobj2; // calls implicitlydeclared // // D::operator=(const D&) // } + @Test public void test13_5_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4459,6 +4752,7 @@ public void test13_5_3s2() throws Exception { // operator++(b); //explicit call: like ++b; // operator++(b, 0); // explicit call: like b++; // } + @Test public void test13_5_7s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4472,6 +4766,7 @@ public void test13_5_7s1() throws Exception { // int& ri = i; // error: nonconst reference bound to temporary // const int& cri = i; // OK: const reference bound to temporary // } + @Test public void test14_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4479,6 +4774,7 @@ public void test14_1s6() throws Exception { // template class X; // error // template class Y; // OK // template class Z; // OK + @Test public void test14_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4491,40 +4787,47 @@ public void test14_1s7() throws Exception { // int v[5]; // R y; // OK due to implicit argument conversion // S z; // OK due to both adjustment and conversion + @Test public void test14_1s8() throws Exception { // TODO raised bug 90668 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class A; // template class A; + @Test public void test14_1s10a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class A; + @Test public void test14_1s10b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class B; // error + @Test public void test14_1s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class X; // template class X { }; // error + @Test public void test14_1s12() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class X { }; // template void f(T* p = new T); + @Test public void test14_1s13() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template 4) > // OK // class Y { }; + @Test public void test14_1s15() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4535,6 +4838,7 @@ public void test14_1s15() throws Exception { // Y< X<1> > x3; // OK // // with C++0x this is no longer valid: // // Y> 1> > x4; // OK: Y< X< (6>>1) > > + @Test public void test14_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4555,6 +4859,7 @@ public void test14_2s3() throws Exception { // T::template adjust<100>(); // // OK: < starts explicit qualification // } + @Test public void test14_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4579,6 +4884,7 @@ public void test14_2s4() throws Exception { // v1[3] = 7; // v2[3] = v3.elem(4) = dcomplex(7,8); // } + @Test public void test14_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4594,6 +4900,7 @@ public void test14_3s1() throws Exception { // // OK: even though Y::S is private // }; // X y; // error: S not accessible + @Test public void test14_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4605,6 +4912,7 @@ public void test14_3s3() throws Exception { // p->A::~A(); // OK: destructor call // q->A::~A(); // OK: destructor call // } + @Test public void test14_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4616,6 +4924,7 @@ public void test14_3s5() throws Exception { // X x3; // error: local type used as templateargument // X x4; // error: pointer to local type used as templateargument // } + @Test public void test14_3_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4626,6 +4935,7 @@ public void test14_3_1s2() throws Exception { // typedef int function(); // A a; // illformed: would declare A::t // // as a static member function + @Test public void test14_3_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4644,6 +4954,7 @@ public void test14_3_1s3() throws Exception { // // so c.y.x has type int // // V within C uses the partial specialization, // // so c.z.x has type long + @Test public void test14_3_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4651,6 +4962,7 @@ public void test14_3_3s2() throws Exception { // template class buffer { }; // buffer x; // buffer y; + @Test public void test14_2s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4660,6 +4972,7 @@ public void test14_2s1a() throws Exception { // list x2; // list x3; // list x4; + @Test public void test14_4s1b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4673,6 +4986,7 @@ public void test14_4s1b() throws Exception { // T& elem(int i) { return v[i]; } // // ... // }; + @Test public void test14_5_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4682,6 +4996,7 @@ public void test14_5_1s2() throws Exception { // void f2(); // }; // template void A::f1() { } // OK + @Test public void test14_5_1s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4701,6 +5016,7 @@ public void test14_5_1s3a() throws Exception { // if (i<0 || sz<=i) error("Array: range error"); // return v[i]; // } + @Test public void test14_5_1_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4711,6 +5027,7 @@ public void test14_5_1_1s1() throws Exception { // v1[3] = 7; // Array::operator[]() // v2[3] = dcomplex(7,8); // Array::operator[]() // } + @Test public void test14_5_1_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4721,6 +5038,7 @@ public void test14_5_1_1s2() throws Exception { // A::B* b1; // OK: requires A to be defined but not A::B // template class A::B { }; // A::B b2; // OK: requires A::B to be defined + @Test public void test14_5_1_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4735,6 +5053,7 @@ public void test14_5_1_2s1() throws Exception { // { // // ... // } + @Test public void test14_5_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4747,6 +5066,7 @@ public void test14_5_2s1() throws Exception { // void f(int i) { f<>(i); } // overriding function that calls // // the template instantiation // }; + @Test public void test14_5_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4764,6 +5084,7 @@ public void test14_5_2s4() throws Exception { // ip = a.operator int*(); // explicit call to template operator // // A::operator int*() // } + @Test public void test14_5_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4772,6 +5093,7 @@ public void test14_5_2s5() throws Exception { // static T s; // }; // template T X::s = 0; + @Test public void test14_5_1_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4788,6 +5110,7 @@ public void test14_5_1_3s1() throws Exception { // template friend class frd; // // ... // }; + @Test public void test14_5_4s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4807,6 +5130,7 @@ public void test14_5_4s1() throws Exception { // }; // } // } + @Test public void test14_5_4s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -4815,6 +5139,7 @@ public void test14_5_4s2() throws Exception { // template friend class B; // OK // template friend void f(T){ } // OK // }; + @Test public void test14_5_4s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4825,6 +5150,7 @@ public void test14_5_4s3() throws Exception { // }; // template struct A { X::Y ab; }; // OK // template struct A { X::Y ab; }; // OK + @Test public void test14_5_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4837,6 +5163,7 @@ public void test14_5_4s4() throws Exception { // template friend struct A::B; // template friend void A::f(); // }; + @Test public void test14_5_4s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4849,6 +5176,7 @@ public void test14_5_4s6() throws Exception { // A::B abcip; // uses #2 // A::B absip; // uses #3 // A::B abci; // uses #1 + @Test public void test14_5_5_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4858,12 +5186,14 @@ public void test14_5_5_3s2() throws Exception { // template class A { }; // #3 // template class A { }; // #4 // template class A { }; // #5 + @Test public void test14_5_5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template struct B {}; // template struct B {}; // OK + @Test public void test14_5_5s9b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4877,6 +5207,7 @@ public void test14_5_5s9b() throws Exception { // A a2; // uses #2, T is int, I is 1 // A a3; // uses #4, T is char // A a4; // uses #5, T1 is int, T2 is char, I is 1 + @Test public void test14_5_5_1s2a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4887,6 +5218,7 @@ public void test14_5_5_1s2a() throws Exception { // template class A { }; // #4 // template class A { }; // #5 // A a5; // ambiguous: matches #3 and #5 : expect problem + @Test public void test14_5_5_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 1); } @@ -4896,6 +5228,7 @@ public void test14_5_5_1s2b() throws Exception { // template class X { }; // #2 // template void f(X); // #A // template void f(X); // #B + @Test public void test14_5_5_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4927,12 +5260,14 @@ public void test14_5_5_2s2() throws Exception { // a2.f(); //illformed, no definition of f for A // // the primary template is not used here // } + @Test public void test14_5_5_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } // template class Array { }; // template void sort(Array&); + @Test public void test14_5_6s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4944,6 +5279,7 @@ public void test14_5_6s1() throws Exception { // f(p); // call // // f(int*) // } + @Test public void test14_5_6_1s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4955,6 +5291,7 @@ public void test14_5_6_1s1a() throws Exception { // f(p); // call // // f(int*) // } + @Test public void test14_5_6_1s1b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -4965,6 +5302,7 @@ public void test14_5_6_1s1b() throws Exception { // template void f/*2*/(A, A); // // Guaranteed to be different // template void f/*3*/(A, A); + @Test public void test14_5_6_1s8a() throws Exception { final String content = getAboveComment(); IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0); @@ -4979,6 +5317,7 @@ public void test14_5_6_1s8a() throws Exception { // // Illformed, no diagnostic required // template void f(A, A); // template void f(A, A); + @Test public void test14_5_6_1s8b() throws Exception { //test is only for syntax, semantics are not checked here. parse(getAboveComment(), ParserLanguage.CPP, false, 0); @@ -4996,6 +5335,7 @@ public void test14_5_6_1s8b() throws Exception { // B b; // b * a; // calls #1a // } + @Test public void test14_5_6_2s3() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5024,6 +5364,7 @@ public void test14_5_6_2s3() throws Exception { // const A z2; // h(z2); // h(const T&) is called because h(A&) is not callable // } + @Test public void test14_5_6_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5037,6 +5378,7 @@ public void test14_5_6_2s5() throws Exception { // f(ip); //calls #2 // g(ip); //calls #4 // } + @Test public void test14_5_6_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5061,6 +5403,7 @@ public void test14_5_6_2s6() throws Exception { // // no visible declarations of B and a8 // } // }; + @Test public void test14_6s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5073,6 +5416,7 @@ public void test14_6s2() throws Exception { // typename T::X x; // illformed: finds the data member X // // not the member type X // } + @Test public void test14_6s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5083,6 +5427,7 @@ public void test14_6s4() throws Exception { // void f(A::B); // illformed: typename required before A::B // typename A::B g(); // OK // }; + @Test public void test14_6s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5104,6 +5449,7 @@ public void test14_6s6() throws Exception { // // not instantiated // } // }; + @Test public void test14_6s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5124,6 +5470,7 @@ public void test14_6s7() throws Exception { // } // // ... // }; + @Test public void test14_6s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5145,12 +5492,14 @@ public void test14_6s8() throws Exception { // // by two calls of f(int) // g('a'); //will cause three calls of f(char) // } + @Test public void test14_6s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } // template class X { }; // template void f(T* p = new T); + @Test public void test14_6_1s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5160,6 +5509,7 @@ public void test14_6_1s3a() throws Exception { // X* p2; // X* p3; // }; + @Test public void test14_6_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5169,6 +5519,7 @@ public void test14_6_1s1() throws Exception { // Y* p; // meaning Y // Y* q; // meaning Y // }; + @Test public void test14_6_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5176,6 +5527,7 @@ public void test14_6_1s2() throws Exception { // template class Array {}; // template class X : public Array { }; // template class Y : public T { }; + @Test public void test14_6_1s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5187,6 +5539,7 @@ public void test14_6_1s3b() throws Exception { // } // }; // template class X; // error: templateparameter redeclared + @Test public void test14_6_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5198,6 +5551,7 @@ public void test14_6_1s4() throws Exception { // template void A::f() { // B b; // A's B, not the template parameter // } + @Test public void test14_6_1s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5211,6 +5565,7 @@ public void test14_6_1s5() throws Exception { // template void N::B::f(C) { // C b; // C is the template parameter, not N::C // } + @Test public void test14_6_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5224,6 +5579,7 @@ public void test14_6_1s6() throws Exception { // B b; // A's B // a b; // error: A's a isn't a type name // }; + @Test public void test14_6_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5236,6 +5592,7 @@ public void test14_6_1s7() throws Exception { // pb->j++; // } // }; + @Test public void test14_6_2s2() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 0); @@ -5253,6 +5610,7 @@ public void test14_6_2s2() throws Exception { // template struct X : B { // A a; // a has type double // }; + @Test public void test14_6_2s3() throws Exception { final String content = getAboveComment(); IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0); @@ -5278,6 +5636,7 @@ public void test14_6_2s3() throws Exception { // Y* p; // Y // }; // Y ya; + @Test public void test14_6_2s4() throws Exception { final String content = getAboveComment(); parse(content, ParserLanguage.CPP, true, 0); @@ -5302,6 +5661,7 @@ public void test14_6_2s4() throws Exception { // }; // void g(int); // not in scope at the point of the template // // definition, not considered for the call g(1) + @Test public void test14_6_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5321,6 +5681,7 @@ public void test14_6_3s1() throws Exception { // // in its namespace (global scope) // b = gcd(3,4); // illformed; gcd is not visible // } + @Test public void test14_6_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5332,6 +5693,7 @@ public void test14_6_5s2() throws Exception { // template T X::s = 0; // X aa; // X bb; + @Test public void test14_7s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5352,6 +5714,7 @@ public void test14_7s6() throws Exception { // p->g(); //instantiation of class Z required, and // // instantiation of Z::g() required // } + @Test public void test14_7_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5367,12 +5730,14 @@ public void test14_7_1s3() throws Exception { // // convert D* to B* // delete ppp; // instantiation of D required // } + @Test public void test14_7_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // template class X; // X ch; // error: definition of X required + @Test public void test14_7_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5391,6 +5756,7 @@ public void test14_7_1s6() throws Exception { // static int x; // }; // template<> int B<>::x = 1; // specialize for T == int + @Test public void test14_7s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5405,6 +5771,7 @@ public void test14_7s3() throws Exception { // f(sr); //instantiation of S allowed but not required // // instantiation of S allowed but not required // }; + @Test public void test14_7_1s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5426,6 +5793,7 @@ public void test14_7_1s5() throws Exception { // int i = m.get("Nicholas"); // // ... // } + @Test public void test14_7_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5438,6 +5806,7 @@ public void test14_7_1s10() throws Exception { // f(a, b); // default argument z = zdef(T()) instantiated // f(a); //illformed; ydef is not declared // } + @Test public void test14_7_1s12() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5448,6 +5817,7 @@ public void test14_7_1s12() throws Exception { // // the implicit instantiation of X which requires // // the implicit instantiation of X which ... // }; + @Test public void test14_7_1s14() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5461,6 +5831,7 @@ public void test14_7_1s14() throws Exception { // template void f(T&) { } // } // template void N::f(int&); + @Test public void test14_7_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5475,6 +5846,7 @@ public void test14_7_2s2() throws Exception { // template class N::Y; // OK: explicit instantiation in namespace N // template void N::Y::mf(); // OK: explicit instantiation // // in namespace N + @Test public void test14_7_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5483,6 +5855,7 @@ public void test14_7_2s5() throws Exception { // template void sort(Array& v); // // instantiate sort(Array&) - templateargument deduced // template void sort<>(Array&); + @Test public void test14_7_2s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5490,6 +5863,7 @@ public void test14_7_2s6() throws Exception { // char* p = 0; // template T g(T = &p); // template int g(int); // OK even though &p isn't an int. + @Test public void test14_7_2s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5499,6 +5873,7 @@ public void test14_7_2s9() throws Exception { // template class Array { }; // template void sort(Array& v) { } // template<> void sort(Array&) ; + @Test public void test14_7_3s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5506,6 +5881,7 @@ public void test14_7_3s1() throws Exception { // template<> class X { }; // error: X not a template // template class X; // template<> class X { }; // OK: X is a template + @Test public void test14_7_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5524,6 +5900,7 @@ public void test14_7_3s3() throws Exception { // // explicit specialization syntax not used for a member of // // explicitly specialized class template specialization // void A::f(int) { } + @Test public void test14_7_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5538,6 +5915,7 @@ public void test14_7_3s5() throws Exception { // template<> void sort(Array& v); // error: specialization // // after use of primary template // template<> void sort<>(Array& v); // OK: sort not yet used + @Test public void test14_7_3s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5552,6 +5930,7 @@ public void test14_7_3s6() throws Exception { // } // template<> class N::Y { }; // OK: specialization // // in same namespace + @Test public void test14_7_3s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5561,6 +5940,7 @@ public void test14_7_3s9() throws Exception { // // explicit specialization for sort(Array&) // // with deduces templateargument of type int // template<> void sort(Array&); + @Test public void test14_7_3s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5572,6 +5952,7 @@ public void test14_7_3s11() throws Exception { // }; // template<> template<> class A::B { }; // template<> template<> void A::B::mf() { }; + @Test public void test14_7_3s17() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5580,6 +5961,7 @@ public void test14_7_3s17() throws Exception { // template<> class X; // X* p; // OK: pointer to declared class X // X x; // error: object of incomplete class X + @Test public void test14_7_3s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5589,6 +5971,7 @@ public void test14_7_3s10() throws Exception { // template <> void f(int*); // Ambiguous // template <> void f(int*); // OK // template <> void f(int); // OK + @Test public void test14_7_3s12() throws Exception { // gcc does not report the explicit instantiation as ambiguous, so we accept it as well. parse(getAboveComment(), ParserLanguage.CPP, true, 0); @@ -5598,6 +5981,7 @@ public void test14_7_3s12() throws Exception { // template inline T g(T) { } // template<> inline void f<>(int) { } // OK: inline // template<> int g<>(int) { } // OK: not inline + @Test public void test14_7_3s14() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5620,6 +6004,7 @@ public void test14_7_3s14() throws Exception { // void A::g(int,char); // X specified as char // // member specialization even if defined in class definition // template<> void A::h(int) { } + @Test public void test14_7_3s16() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5637,6 +6022,7 @@ public void test14_7_3s16() throws Exception { // template template<> // void A::B::mf2() { }; // illformed; B is specialized but // // its enclosing class template A is not + @Test public void test14_7_3s18() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5651,6 +6037,7 @@ public void test14_7_3s18() throws Exception { // f(&a); //call f(int*) // f(&b); //call f(char**) // } + @Test public void test14_8s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5667,6 +6054,7 @@ public void test14_8s2() throws Exception { // int i = convert(d); // int convert(double) // char c = convert(d); // char convert(double) // } + @Test public void test14_8_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5677,6 +6065,7 @@ public void test14_8_1s1() throws Exception { // int i = f(5.6); // Y is deduced to be double // int j = f(5.6); // illformed: X cannot be deduced // } + @Test public void test14_8_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5690,6 +6079,7 @@ public void test14_8_1s2() throws Exception { // // Z is deduced to be double // f("aa",3.0); //error: X cannot be deduced // } + @Test public void test14_8_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5703,6 +6093,7 @@ public void test14_8_1s3() throws Exception { // { // f(1); // OK, means f(Complex(1)) // } + @Test public void test14_8_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5723,6 +6114,7 @@ public void test14_8_1s4() throws Exception { // f<3>(b); //wellformed because C::f is visible; then // // A::f is found by argument dependent lookup // } + @Test public void test14_8_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5737,6 +6129,7 @@ public void test14_8_1s6() throws Exception { // int i = convert(d); // call convert(double) // int c = convert(d); // call convert(double) // } + @Test public void test14_8_2s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5757,6 +6150,7 @@ public void test14_8_2s1() throws Exception { // // #5: function type is h(int, const int*) // h(1,0); // } + @Test public void test14_8_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5770,6 +6164,7 @@ public void test14_8_2s3() throws Exception { // f(); // f(0,0) // f(); // f(0,0) // } + @Test public void test14_8_2s5() throws Exception { final String content = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(content, true); @@ -5793,6 +6188,7 @@ public void test14_8_2s5() throws Exception { // X f(Y, Y); // #2 // X x1, x2; // X x3 = f(x1, x2); // deduction fails on #1 (cannot add X+X), calls #2 + @Test public void test14_8_2s8a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -5809,6 +6205,7 @@ public void _test14_8_2s8b() throws Exception { // template int f(typename T::B*); // int i = f(0); + @Test public void test14_8_2s8c() throws Exception { final String content = getAboveComment(); IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 2); @@ -5837,6 +6234,7 @@ public void test14_8_2s8c() throws Exception { // g(0); // The N member of C is not a non-type // h(0); // The TT member of D is not a template // } + @Test public void test14_8_2s8d() throws Exception { final String content = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(content, true); @@ -5848,6 +6246,7 @@ public void test14_8_2s8d() throws Exception { // template int f(int T::*); // int i = f(0); + @Test public void test14_8_2s8e() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 2); @@ -5859,6 +6258,7 @@ public void test14_8_2s8e() throws Exception { // template int f(S*); // struct X {}; // int i0 = f(0); + @Test public void test14_8_2s8f() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 2); @@ -5868,6 +6268,7 @@ public void test14_8_2s8f() throws Exception { // template int f(int); // int i2 = f(0); // can't conv 1 to int* + @Test public void test14_8_2s8g() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 1); } @@ -5876,6 +6277,7 @@ public void test14_8_2s8g() throws Exception { // template int f(int); // int i1 = f<1>(0); // ambiguous // int i2 = f<1000>(0); // ambiguous + @Test public void test14_8_2s9() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 2); } @@ -5890,6 +6292,7 @@ public void test14_8_2s9() throws Exception { // f({1,"asdf"}); // error: T deduced to both int and const char* // g({1,2,3}); // error: no argument deduced for T // } + @Test public void test14_8_2_1s1a() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5908,6 +6311,7 @@ public void test14_8_2_1s1a() throws Exception { // f(x, y, z); // Types is deduced to int, float, const int // g(x, y, z); // T1 is deduced to int; Types is deduced to float, int // } + @Test public void test14_8_2_1s1b() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5926,6 +6330,7 @@ public void test14_8_2_1s1b() throws Exception { // int n2 = f(0); // calls f(int&&) // int n3 = g(i); // error: would call g(const int&&), which // // would bind an rvalue reference to an lvalue + @Test public void test14_8_2_1s3() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5943,6 +6348,7 @@ public void test14_8_2_1s3() throws Exception { // int g(int); // int g(char); // int i = f(g); // calls f(int (*)(int)) + @Test public void test14_8_2_1s7() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5957,6 +6363,7 @@ public void test14_8_2_1s7() throws Exception { // int g(int); // char g(char); // int i = f(1, g); // calls f(int, int (*)(int)) + @Test public void test14_8_2_1s8() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5971,6 +6378,7 @@ public void test14_8_2_1s8() throws Exception { // char g(char); // template T g(T); // int i = f(1, g); // calls f(int, int (*)(int)) + @Test public void test14_8_2_1s9() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5986,6 +6394,7 @@ public void test14_8_2_1s9() throws Exception { // void test(const int * const * const * p1) { // test(a); // T is deduced as int, not const int // } + @Test public void test14_8_2_3s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -5995,6 +6404,7 @@ public void test14_8_2_3s7() throws Exception { // void g() { // f(1); // calls #1 // } + @Test public void test14_8_2_4s11() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6009,6 +6419,7 @@ public void test14_8_2_4s11() throws Exception { // g(Tuple()); // calls #3 // g(Tuple()); // calls #3 // } + @Test public void test14_8_2_4s12() throws Exception { final String code = getAboveComment(); parse(code, ParserLanguage.CPP, true, 0); @@ -6032,6 +6443,7 @@ public void test14_8_2_4s12() throws Exception { // void test() { // g({1,2,3}); // error: no argument deduced for T // } + @Test public void test14_8_2_5s5() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6048,6 +6460,7 @@ public void test14_8_2_5s5() throws Exception { // f(a,a); //OK: T is A // f(b,b); //OK: T is B // } + @Test public void test14_8_2_5s7a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6062,6 +6475,7 @@ public void test14_8_2_5s7a() throws Exception { // f(g2); //error: T could be char or int // f(g3); //error: U could be char or float // } + @Test public void test14_8_2_5s7b() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6078,6 +6492,7 @@ public void test14_8_2_5s7b() throws Exception { // { // f(p); // f(const int *) // } + @Test public void test14_8_2_5s7c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6093,6 +6508,7 @@ public void test14_8_2_5s7c() throws Exception { // f(d); //calls f(B&) // f(d2); //calls f(B&) // } + @Test public void test14_8_2_5s7d() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6104,6 +6520,7 @@ public void test14_8_2_5s7d() throws Exception { // f(i); // calls f(int&), i.e., #1 // f(0); // calls f(int&&), i.e., #2 // } + @Test public void test14_8_2_5s10() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6120,6 +6537,7 @@ public void test14_8_2_5s10() throws Exception { // f(v); //error: argument for templateparameter // //T cannot be deduced // } + @Test public void test14_8_2_5s14() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6138,6 +6556,7 @@ public void test14_8_2_5s14() throws Exception { // f2<10>(v); //OK // f3(v); //OK: i deduced to be 10 // } + @Test public void test14_8_2_5s15() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6163,6 +6582,7 @@ public void test14_8_2_5s15() throws Exception { // g<0>(a1); // OK // f(a1, a2); // OK // } + @Test public void test14_8_2_5s16a() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6193,6 +6613,7 @@ public void test14_8_2_5s16a() throws Exception { // B<77> b; // deduce<77> (a.xm, 62, b.ym); // } + @Test public void test14_8_2_5s16b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6210,6 +6631,7 @@ public void test14_8_2_5s16b() throws Exception { // B<1> b; // g(b); // OK: cv-qualifiers are ignored on template parameter types // } + @Test public void test14_8_2_5s17() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6232,6 +6654,7 @@ public void test14_8_2_5s17() throws Exception { // f(&h); // OK: void h(char,int) is a unique match // f(&foo); // error: type deduction fails because foo is a template // } + @Test public void test14_8_2_5s18() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6248,6 +6671,7 @@ public void test14_8_2_5s18() throws Exception { // f(); // error: cannot deduce T // f(); // OK: call f(5,7) // } + @Test public void test14_8_2_5s19() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6266,6 +6690,7 @@ public void test14_8_2_5s19() throws Exception { // A ab; // f(ab); //calls f(A) // } + @Test public void test14_8_2_4s20() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6283,6 +6708,7 @@ public void test14_8_2_4s20() throws Exception { // Y y2; // uses partial specialization; T is int&, Types contains float, double // Y y3; // uses primary template; Types contains int, float, double // int fv = f(g); // OK; Types contains int, float + @Test public void test14_8_2_4s21() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6296,6 +6722,7 @@ public void test14_8_2_4s21() throws Exception { // f(1, 2); // calls #3; non-variadic template #3 is more // // specialized than the variadic templates #1 and #2 // } + @Test public void test14_8_2_5s22() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6319,6 +6746,7 @@ public void test14_8_2_5s22() throws Exception { // char m2 = max(c,d); // max(char a, char b) // int m3 = max(a,c); // error: cannot generate max(int,char) // } + @Test public void test14_8_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6331,6 +6759,7 @@ public void test14_8_3s2() throws Exception { // char m2 = max(c,d); // max(char a, char b) // int m3 = max(a,c); // resolved // } + @Test public void test14_8_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6343,6 +6772,7 @@ public void test14_8_3s3() throws Exception { // f(bi); // f(bi) // f(di); // f( (B&)di ) // } + @Test public void test14_8_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6356,6 +6786,7 @@ public void test14_8_3s4() throws Exception { // f(i,c); //#2: f(i,c); // f(i,i); //#2: f(i,char(i)) // } + @Test public void test14_8_3s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6364,6 +6795,7 @@ public void test14_8_3s5() throws Exception { // void g() { // f("Annemarie"); // call of f // } + @Test public void test14_8_3s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6380,6 +6812,7 @@ public void test14_8_3s6() throws Exception { // } catch(...) { // handler 1 // } // } + @Test public void test15s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6402,6 +6835,7 @@ public void test15s2() throws Exception { // // handles exceptions thrown from the ctorinitializer // // and from the constructor function body // } + @Test public void test15s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6426,6 +6860,7 @@ public void test15s3() throws Exception { // // handle exceptions of type Overflow here // } // } + @Test public void test15_1s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6440,6 +6875,7 @@ public void test15_1s1() throws Exception { // // other handler // } // } + @Test public void test15_1s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6459,6 +6895,7 @@ public void test15_1s6() throws Exception { // // ... // } // } + @Test public void test15_3s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6466,11 +6903,13 @@ public void test15_3s4() throws Exception { // void f() throw(int); // OK // void (*fp)() throw (int); // OK // void g(void pfa() throw(int)); // OK + @Test public void test15_4s1a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // typedef int (*pf)() throw(int); // illformed + @Test public void test15_4s1b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6486,6 +6925,7 @@ public void test15_4s1b() throws Exception { // f(a); // g(a); // } + @Test public void test15_4s1c() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6498,6 +6938,7 @@ public void test15_4s1c() throws Exception { // void f(); // illformed // void g() throw (int); // OK // }; + @Test public void test15_4s3a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6510,6 +6951,7 @@ public void test15_4s3a() throws Exception { // pf1 = pf2; // OK: pf1 is less restrictive // pf2 = pf1; // error: pf2 is more restrictive // } + @Test public void test15_4s3b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6525,6 +6967,7 @@ public void test15_4s3b() throws Exception { // if (n) throw Z(); // also OK // throw W(); // will call unexpected() // } + @Test public void test15_4s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6534,6 +6977,7 @@ public void test15_4s8() throws Exception { // { // // f(); //OK // } + @Test public void test15_4s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6553,6 +6997,7 @@ public void test15_4s10() throws Exception { // // Implicit declaration of D::D(const D&) throw(); // // Implicit declaration of D::~D() throw (X,Y); // }; + @Test public void test15_4s13() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6564,6 +7009,7 @@ public void test15_4s13() throws Exception { // #else // #define INCFILE "versN.h" // #endif + @Test public void test16_2s8() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6578,6 +7024,7 @@ public void test16_2s8() throws Exception { // a = ((a + 32765) + b); // a = (a + (b + 32765)); // } + @Test public void test18_2_1_5s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6586,6 +7033,7 @@ public void test18_2_1_5s2() throws Exception { // enum E { z = 16 }; // int b[X::z]; // OK // }; + @Test public void test3_3_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6598,6 +7046,7 @@ public void test3_3_1s4() throws Exception { // f(a); // } // }; + @Test public void test3_4_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6616,6 +7065,7 @@ public void test3_4_1s3() throws Exception { // F f; // f.A::a = 1; // OK, A::a is a member of F // } + @Test public void test3_4_5s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6626,6 +7076,7 @@ public void test3_4_5s4() throws Exception { // // may be statically initialized to 0.0 or // // dynamically initialized to 1.0 // double d1 = fd(); // may be initialized statically to 1.0 + @Test public void test3_6_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6637,6 +7088,7 @@ public void test3_6_2s2() throws Exception { // *pcc = &c; // *pc = 'C'; //2: modifies a const object // } + @Test public void test4_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6649,6 +7101,7 @@ public void test4_4s4() throws Exception { // int S::* pm = &S::i; // pm refers to mutable member S::i // cs.*pm = 88; // illformed: cs is a const object // } + @Test public void test5_5s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6670,6 +7123,7 @@ public void test5_5s5() throws Exception { // g(); //okay: name g refers to the same entity // h(); //error: name h found in two namespaces // } + @Test public void test7_3_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6677,6 +7131,7 @@ public void test7_3_4s4() throws Exception { // int a; // const int b = a; // int c = b; + @Test public void test8_5s14() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6690,6 +7145,7 @@ public void test8_5s14() throws Exception { // struct D2 : D { // void f(); // }; + @Test public void test10_3s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6706,6 +7162,7 @@ public void test10_3s3() throws Exception { // B* bp = new D; // delete bp; //1: uses D::operator delete(void*) // } + @Test public void test12_5s7a() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6724,6 +7181,7 @@ public void test12_5s7a() throws Exception { // B* bp = new D[i]; // delete[] bp; // undefined behavior // } + @Test public void test12_5s7b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6739,6 +7197,7 @@ public void test12_5s7b() throws Exception { // //operator+ (a,a); // ERROR - global operator hidden by member // a + a; // OK - calls global operator+ // } + @Test public void test13_3_1_2s10() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6750,6 +7209,7 @@ public void test13_3_1_2s10() throws Exception { // C value; // // ... // }; + @Test public void test14_1s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6761,6 +7221,7 @@ public void test14_1s2() throws Exception { // T t1 = i; // templateparameters T and i // ::T t2 = ::i; // global namespace members T and i // } + @Test public void test14_1s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6772,6 +7233,7 @@ public void test14_1s3() throws Exception { // X<&s.m> x4; // error: address of nonstatic member // X<&s.s> x5; // error: &S::s must be used // X<&S::s> x6; // OK: address of static member + @Test public void test14_3_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6784,6 +7246,7 @@ public void test14_3_2s3() throws Exception { // X x1; // error: string literal as template argument // char p[] = "Vivisectionist"; // X x2; // OK + @Test public void test14_3_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6792,6 +7255,7 @@ public void test14_3_2s2() throws Exception { // B<1> b2; // error: temporary would be required for template argument // int c = 1; // B b1; // OK + @Test public void test14_3_2s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6810,6 +7274,7 @@ public void test14_3_2s4() throws Exception { // void f(int); // template struct A { }; // A<&f> a; // selects f(int) + @Test public void test14_3_2s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6827,11 +7292,13 @@ public void test14_3_2s5() throws Exception { // ac.f('c'); //template // ac.f<>(1); //template // } + @Test public void test14_5_2s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); //should be 0 } // template class A { }; // error + @Test public void test14_5_5s5() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -6845,6 +7312,7 @@ public void test14_5_5s5() throws Exception { // template template // struct A::C::B { }; // A::C::B absip; // uses partial specialization + @Test public void test14_5_5s6() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6858,6 +7326,7 @@ public void test14_5_5s6() throws Exception { // } // A a; // uses the partial specialization, which is found through // // the using declaration which refers to the primary template + @Test public void test14_5_5s7() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6865,6 +7334,7 @@ public void test14_5_5s7() throws Exception { // template void f(); // template void f(); // OK: overloads the first template // // distinguishable with an explicit template argument list + @Test public void test14_5_6_1s4() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6873,6 +7343,7 @@ public void test14_5_6_1s4() throws Exception { // template A f/*1*/(A, A); // #1 // template A f/*2*/(A, A); // same as #1 // template A f/*3*/(A, A); // different from #1 + @Test public void test14_5_6_1s5() throws Exception { final String content = getAboveComment(); IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0); @@ -6887,6 +7358,7 @@ public void test14_5_6_1s5() throws Exception { // template class A; // template void f/*1*/(A); // #1 // template void f/*2*/(A); // same as #1 + @Test public void test14_5_6_1s6() throws Exception { final String content = getAboveComment(); IASTTranslationUnit tu = parse(content, ParserLanguage.CPP, true, 0); @@ -6900,12 +7372,14 @@ public void test14_5_6_1s6() throws Exception { // int f(int); // #2 // int k = f(1); // uses #2 // int l = f<>(1); // uses #1 + @Test public void test14_8_1s2b() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } // #define TABSIZE 100 // int table[TABSIZE]; + @Test public void test15_3_5s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6924,6 +7398,7 @@ public void test15_3_5s3() throws Exception { // int (&ra)[3] = a; // ra refers to the array a // ra[1] = i; // modifies a[1] // } + @Test public void test8_5_3s1() throws Exception { // TODO raised bug 90648 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6936,6 +7411,7 @@ public void test8_5_3s1() throws Exception { // TODO raised bug 90648 // this->A::operator=(s); // wellformed // return *this; // } + @Test public void test12s1() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6957,6 +7433,7 @@ public void test12s1() throws Exception { // // C/B/D/A sublattice is fully constructed // { } // }; + @Test public void test12_7s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6979,6 +7456,7 @@ public void test12_7s2() throws Exception { // class D { // typedef I I; // error, even though no reordering involved // }; + @Test public void test3_3_6s5() throws Exception { // 90606 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -6993,6 +7471,7 @@ public void test3_3_6s5() throws Exception { // 90606 // void g() { // (int (*)(int))&f; // cast expression as selector // } + @Test public void test13_4s5a() throws Exception { // bug 90674 parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -7028,6 +7507,7 @@ public void test13_4s5a() throws Exception { // bug 90674 // }; // int ef(D&); // int ff(X&); + @Test public void test11_3s2() throws Exception { //bug 92793 IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.CPP, true, 0); IASTCompositeTypeSpecifier D = getCompositeType(tu, 2); @@ -7041,6 +7521,7 @@ public void test11_3s2() throws Exception { //bug 92793 // int b = f(a); // int c(b); // } + @Test public void test8_5s2() throws Exception { // 90641 parse(getAboveComment(), ParserLanguage.CPP, true, 0); } @@ -7053,6 +7534,7 @@ public void test8_5s2() throws Exception { // 90641 // new (int(*p)) int; // newplacement expression // new (int(*[x])); // new typeid // } + @Test public void test8_2s3() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, false, 0); } @@ -7063,6 +7545,7 @@ public void test8_2s3() throws Exception { // { // f(); // int() is a typeid:call the first f() // } + @Test public void test14_3s2() throws Exception { parse(getAboveComment(), ParserLanguage.CPP, true, 0); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java index 53eaee20412..623341d6704 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTestBase.java @@ -18,12 +18,6 @@ import org.eclipse.cdt.internal.core.parser.ParserException; public abstract class AST2CPPTestBase extends AST2TestBase { - public AST2CPPTestBase() { - } - - public AST2CPPTestBase(String name) { - super(name); - } protected IASTTranslationUnit parseAndCheckBindings(String code) throws Exception { return parseAndCheckBindings(code, ScannerKind.STD); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index 97ae091bb2a..c2d7e7ce9f2 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -25,7 +25,14 @@ import static org.eclipse.cdt.core.dom.ast.IASTExpression.ValueCategory.XVALUE; import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; import static org.eclipse.cdt.core.parser.tests.VisibilityAsserts.assertVisibility; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.BufferedReader; import java.io.StringReader; @@ -170,22 +177,11 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil; import org.eclipse.cdt.internal.core.parser.ParserException; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; public class AST2CPPTests extends AST2CPPTestBase { - public AST2CPPTests() { - } - - public AST2CPPTests(String name) { - super(name); - } - - public static TestSuite suite() { - return suite(AST2CPPTests.class); - } - private void assertProblemBinding(int id, IBinding b) { assertTrue(b instanceof IProblemBinding); assertEquals(id, ((IProblemBinding) b).getID()); @@ -242,15 +238,15 @@ private void checkDeclDef(String[] declNames, String[] defNames, IASTDeclaration final String name = dtor.getName().toString(); switch (dtor.getRoleForName(dtor.getName())) { case IASTNameOwner.r_declaration: - assertTrue("Unexpected decl " + name, i < declNames.length); + assertTrue(i < declNames.length, "Unexpected decl " + name); assertEquals(declNames[i++], name); break; case IASTNameOwner.r_definition: - assertTrue("Unexpected decl " + name, j < defNames.length); + assertTrue(j < defNames.length, "Unexpected decl " + name); assertEquals(defNames[j++], name); break; default: - assertTrue(name, false); + assertTrue(false, name); } } } @@ -261,8 +257,8 @@ private void checkDeclDef(String[] declNames, String[] defNames, IASTDeclaration protected static void assertSameType(IType first, IType second) { assertNotNull(first); assertNotNull(second); - assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second - + "'", first.isSameType(second)); + assertTrue(first.isSameType(second), "Expected types to be the same, but first was: '" + first.toString() + + "' and second was: '" + second + "'"); } private void checkUserDefinedLiteralIsType(String code, String type_name) throws Exception { @@ -284,6 +280,7 @@ private void checkUserDefinedLiteralIsRet(String code) throws Exception { // int (*zzz2) (char); // int ((*zzz3)) (char); // int (*(zzz4)) (char); + @Test public void testBug40768() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -291,6 +288,7 @@ public void testBug40768() throws Exception { assertNoProblemBindings(col); } + @Test public void testBug40422() throws Exception { IASTTranslationUnit tu = parse("class A { int y; }; int A::* x = 0;", CPP); NameCollector col = new NameCollector(); @@ -298,6 +296,7 @@ public void testBug40422() throws Exception { assertNoProblemBindings(col); } + @Test public void testBug43241() throws Exception { parseAndCheckBindings("int m(int); int (*pm)(int) = &m; int f(){} int f(int); int x = f((*pm)(5));"); } @@ -308,6 +307,7 @@ public void testBug43241() throws Exception { // int f(){} // int f(int); // int x = f((a.*pm)(5)); + @Test public void testBug43242() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -320,14 +320,17 @@ public void testBug43242() throws Exception { // int f(){} // int f(int); // int x = f(a->*pm); + @Test public void testBug43579() throws Exception { parseAndCheckBindings(); } + @Test public void testBug75189() throws Exception { parseAndCheckBindings("struct A{};typedef int (*F) (A*);"); } + @Test public void testBug75340() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings("void f(int i = 0, int * p = 0);"); IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -339,6 +342,7 @@ public void testBug75340() throws Exception { // if (first < 1 || last > 99) // return false; // } + @Test public void testBug75858() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -351,6 +355,7 @@ public void testBug75858() throws Exception { // type c; // enum type2 {A, B}; // enum type2 d, e; + @Test public void testBug77967() throws Exception { parseAndCheckBindings(); } @@ -365,6 +370,7 @@ public void testBug77967() throws Exception { // p2 = &MyStruct.b; // MyStruct.b = 1; // } + @Test public void testBug78103() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -378,6 +384,7 @@ public void testBug78103() throws Exception { // A(int t); // }; // A::A(int t) : B(t - 1) {} + @Test public void testBug78883() throws Exception { parseAndCheckBindings(); } @@ -388,10 +395,12 @@ public void testBug78883() throws Exception { // B(); // void foo(); // }; + @Test public void testBug79540() throws Exception { parseAndCheckBindings(getAboveComment()); } + @Test public void testBug86282() throws Exception { IASTTranslationUnit tu = parse("void foo() { int (* f[])() = new (int (*[10])()); }", CPP); NameCollector col = new NameCollector(); @@ -412,6 +421,7 @@ public void testBug86282() throws Exception { // for(int x = 0 ; x < 10; x++) { // } // } + @Test public void testBug95411() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector nameCol = new NameCollector(); @@ -419,6 +429,7 @@ public void testBug95411() throws Exception { assertNoProblemBindings(nameCol); } + @Test public void testBug95424() throws Exception { IASTTranslationUnit tu = parse("void f(){ traits_type::copy(__r->_M_refdata(), __buf, __i); }", CPP, ScannerKind.GNU, true); @@ -435,6 +446,7 @@ public void testBug95424() throws Exception { // CINIT(FILE, OBJECTPOINT, 1), // CINIT(URL, OBJECTPOINT, 2) // } CURLoption; + @Test public void testBug102825() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -447,6 +459,7 @@ public void testBug102825() throws Exception { // WithTemplate brokenInstance; // return 0; // } + @Test public void testBug103578() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -462,11 +475,13 @@ public void testBug103578() throws Exception { // struct A::B { // typedef typename A::type type; // }; + @Test public void testBug433556() throws Exception { parseAndCheckBindings(); } // class A { } a; + @Test public void testSimpleClass() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTSimpleDeclaration decl = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -485,6 +500,7 @@ public void testSimpleClass() throws Exception { } // class A; class A {}; + @Test public void testClassForwardDecl() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -506,6 +522,7 @@ public void testClassForwardDecl() throws Exception { } // class A {}; A a; + @Test public void testVariable() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -532,6 +549,7 @@ public void testVariable() throws Exception { } // class A { int f; }; + @Test public void testField() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -553,6 +571,7 @@ public void testField() throws Exception { } // class A { int f(); }; + @Test public void testMethodDeclaration() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -575,6 +594,7 @@ public void testMethodDeclaration() throws Exception { // class A { void f(); }; // void A::f() { } + @Test public void testMethodDefinition() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -612,6 +632,7 @@ public void testMethodDefinition() throws Exception { // class A { void f(); int i; }; // void A::f() { i; } + @Test public void testMemberReference() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -663,6 +684,7 @@ public void testMemberReference() throws Exception { // class A { int i; }; // class B : public A { void f(); }; // void B::f() { i; } + @Test public void testBasicInheritance() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -733,6 +755,7 @@ public void testBasicInheritance() throws Exception { // void f(){ // BC::a++; //ok // } + @Test public void testNamespaces() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -760,6 +783,7 @@ public void testNamespaces() throws Exception { // A++; // class A a; // } + @Test public void testNameHiding() throws Exception { String content = getAboveComment(); IASTTranslationUnit tu = parse(content, CPP); @@ -792,6 +816,7 @@ public void testNameHiding() throws Exception { // B b; // } // int B; + @Test public void testBlockTraversal() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -818,6 +843,7 @@ public void testBlockTraversal() throws Exception { // f(1); //calls f(int); // f('b'); // } + @Test public void testFunctionResolution() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -836,6 +862,7 @@ public void testFunctionResolution() throws Exception { // S myS; // myS.x = 5; // } + @Test public void testSimpleStruct() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -858,6 +885,7 @@ public void testSimpleStruct() throws Exception { // struct A; // struct A * a; // } + @Test public void testStructureTags_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -879,6 +907,7 @@ public void testStructureTags_a() throws Exception { // void f(){ // struct A * a; // } + @Test public void testStructureTags_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -901,6 +930,7 @@ public void testStructureTags_b() throws Exception { // void f() { // a->i; // } + @Test public void testStructureDef() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -919,6 +949,7 @@ public void testStructureDef() throws Exception { // void f(int x) { // struct x i; // } + @Test public void testStructureNamespace() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -933,6 +964,7 @@ public void testStructureNamespace() throws Exception { // void f(int b){ // b; // } + @Test public void testFunctionDef() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -954,6 +986,7 @@ public void testFunctionDef() throws Exception { // f(); // } // void f(){ } + @Test public void testSimpleFunctionCall() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -971,6 +1004,7 @@ public void testSimpleFunctionCall() throws Exception { // i; // } // } + @Test public void testForLoop() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -985,6 +1019,7 @@ public void testForLoop() throws Exception { // void f(){ // ((struct A *) 1)->x; // } + @Test public void testExpressionFieldReference() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1005,6 +1040,7 @@ public void testExpressionFieldReference() throws Exception { // if (*cp != red) // return; // } + @Test public void testEnumerations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1029,6 +1065,7 @@ public void testEnumerations() throws Exception { assertSame(pt.getType(), hue); } + @Test public void testPointerToFunction() throws Exception { IASTTranslationUnit tu = parse("int (*pfi)();", CPP); NameCollector collector = new NameCollector(); @@ -1056,6 +1093,7 @@ public void testPointerToFunction() throws Exception { // int * f(int i, char c); // void (*g) (A *); // void (* (*h)(A**)) (int); + @Test public void testFunctionTypes() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -1121,6 +1159,7 @@ public void testFunctionTypes() throws Exception { assertTrue(h_ps[0] instanceof IBasicType); } + @Test public void testFnReturningPtrToFn() throws Exception { IASTTranslationUnit tu = parse("void (* f(int))(){}", CPP); @@ -1145,6 +1184,7 @@ public void testFnReturningPtrToFn() throws Exception { // X::f(); // X::g(); // } + @Test public void testUsingDeclaration() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1182,6 +1222,7 @@ public void testUsingDeclaration() throws Exception { // using A::f; // f('c'); // } + @Test public void testUsingDeclaration_86368() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IFunction f1 = bh.assertNonProblem("f(int)", 1); @@ -1209,6 +1250,7 @@ public void testUsingDeclaration_86368() throws Exception { // void g(char []); // void h(int(a)()); // void h(int (*) ()); + @Test public void testFunctionDeclarations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1233,6 +1275,7 @@ public void testFunctionDeclarations() throws Exception { // B * b = new B(); // b->x; // } + @Test public void testProblem_AmbiguousInParent() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1250,6 +1293,7 @@ public void testProblem_AmbiguousInParent() throws Exception { // A * a = new A(); // a->x; // } + @Test public void testVirtualParentLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(true); @@ -1279,6 +1323,7 @@ public void testVirtualParentLookup() throws Exception { // A * a = new A(); // a->x; // } + @Test public void testAmbiguousVirtualParentLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(true); @@ -1310,6 +1355,7 @@ public void testAmbiguousVirtualParentLookup() throws Exception { // namespace A { // void f() { x; } // } + @Test public void testExtendedNamespaces() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -1327,6 +1373,7 @@ public void testExtendedNamespaces() throws Exception { } // class A { A(void); A(const A &); }; + @Test public void testConstructors() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -1350,6 +1397,7 @@ public void testConstructors() throws Exception { } // class A {}; + @Test public void testImplicitConstructors() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -1385,6 +1433,7 @@ public void testImplicitConstructors() throws Exception { // }; // typedef E F; // F::E() {} + @Test public void testImplicitConstructors_360223() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPClassType c = bh.assertNonProblem("C", 0); @@ -1407,6 +1456,7 @@ public void testImplicitConstructors_360223() throws Exception { // template // struct Bar { }; // constexpr int v = Bar::val; + @Test public void testImplicitConstructors_1265() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(true); @@ -1431,6 +1481,7 @@ public void testImplicitConstructors_1265() throws Exception { // int test() { // foo(1); // } + @Test public void testInheritedConstructor() throws Exception { parseAndCheckBindings(); } @@ -1449,6 +1500,7 @@ public void testInheritedConstructor() throws Exception { // int test() { // foo(1); // } + @Test public void testInheritedConstructorFromTemplateInstance() throws Exception { parseAndCheckBindings(); } @@ -1467,6 +1519,7 @@ public void testInheritedConstructorFromTemplateInstance() throws Exception { // int test() { // foo(1); // } + @Test public void testInheritedConstructorFromUnknownClass() throws Exception { parseAndCheckBindings(); } @@ -1488,6 +1541,7 @@ public void testInheritedConstructorFromUnknownClass() throws Exception { // void test(A a) { // foo(a); // } + @Test public void testInheritedTemplateConstructor() throws Exception { parseAndCheckBindings(); } @@ -1498,12 +1552,14 @@ public void testInheritedTemplateConstructor() throws Exception { // using base::base; // base waldo() const; // }; + @Test public void testInheritedConstructorShadowingBaseClassName_485383() throws Exception { parseAndCheckBindings(); } // class A { ~A(); }; // class B { ~B(void); }; + @Test public void testExplicitDestructor_183160() throws Exception { // class F { (~)F(); }; // class G { (~)G(void); }; @@ -1520,20 +1576,21 @@ public void testExplicitDestructor_183160() throws Exception { int count = 0; for (ICPPMethod method : methods) count += method.getName().startsWith("~") ? 1 : 0; - assertEquals(line, 0, count); + assertEquals((long) 0, (long) count, line); methods = A.getDeclaredMethods(); assertNotNull(methods); count = 0; for (ICPPMethod method : methods) count += method.getName().startsWith("~") ? 1 : 0; - assertEquals(line, 1, count); + assertEquals((long) 1, (long) count, line); } } // class C {}; // class D {D();}; // class E {E(void);}; + @Test public void testImplicitDestructor_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1547,14 +1604,14 @@ public void testImplicitDestructor_183160() throws Exception { int count = 0; for (ICPPMethod method : methods) count += method.getName().startsWith("~") ? 1 : 0; - assertEquals(line, 1, count); + assertEquals((long) 1, (long) count, line); methods = A.getDeclaredMethods(); assertNotNull(methods); count = 0; for (ICPPMethod method : methods) count += method.getName().startsWith("~") ? 1 : 0; - assertEquals(line, 0, count); + assertEquals((long) 0, (long) count, line); } } @@ -1578,6 +1635,7 @@ public void testImplicitDestructor_183160() throws Exception { // class R {public: R(int k=5, long k=4);}; // class S {public: S(int k=5, int* ip= 0);}; // class T {public: T(int k=5, int* ip= 0, T* t= 0);}; + @Test public void testExplicitDefaultConstructor_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1596,6 +1654,7 @@ public void testExplicitDefaultConstructor_183160() throws Exception { // class R {public: R(int k=5, long k);}; // class S {public: S(int k=5, int* ip);}; // class T {public: T(int k, int* ip= 0, T* t= 0);}; + @Test public void testExplicitNonDefaultConstructor_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1618,6 +1677,7 @@ public void testExplicitNonDefaultConstructor_183160() throws Exception { // class F {private: F(const F &, int j=2, int k=3);}; // class G {protected: G(volatile G &, int i=4, int l=2);}; // class H {H(const volatile H &, int i=1, long k=2) {}}; + @Test public void testExplicitCopyConstructor_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1638,6 +1698,7 @@ public void testExplicitCopyConstructor_183160() throws Exception { // class K {protected: K(volatile K *, int i=4, int l=2);}; // K * rather than K & // class L {L(const volatile L &, int i=1, long k=2, int* x) {}}; // param int* x has no initializer // class M {public: template M(){}}; // same signature as implicit + @Test public void testNotExplicitCopyConstructor_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1657,6 +1718,7 @@ public void testNotExplicitCopyConstructor_183160() throws Exception { // class B {public: void operator=(B &, int); }; // compile error // class C {public: void operator=(C &c, int k=5) {} }; // compile error // class D {public: void operator=(const D &, const D &); }; // compile error + @Test public void testNotExplicitCopyAssignmentOperator_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1690,6 +1752,7 @@ public void testNotExplicitCopyAssignmentOperator_183160() throws Exception { // class B {protected: void operator=(const B &); }; // class C {private: void operator=(volatile C &) {} }; // class D {D& operator=(volatile const D &); }; + @Test public void testExplicitCopyAssignmentOperator_183160() throws Exception { BufferedReader br = new BufferedReader(new StringReader(getAboveComment())); for (String line = br.readLine(); line != null; line = br.readLine()) { @@ -1725,6 +1788,7 @@ public void testExplicitCopyAssignmentOperator_183160() throws Exception { // }; // // A a = A(1); + @Test public void testConstructorCall() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPConstructor ctor = bh.assertNonProblem("A(int x)", "A", ICPPConstructor.class); @@ -1744,6 +1808,7 @@ public void testConstructorCall() throws Exception { // void test() { // A a("hi", 5, 10); // } + @Test public void testInvalidImplicitConstructorCall() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("a", 1, IProblemBinding.class); @@ -1779,6 +1844,7 @@ public void _testConversionOperator() throws Exception { // S s; // waldo(s); // ERROR // } + @Test public void testOverloadedRefQualifiedConversionOperators_506728() throws Exception { parseAndCheckBindings(); } @@ -1786,6 +1852,7 @@ public void testOverloadedRefQualifiedConversionOperators_506728() throws Except // namespace A { int x; } // namespace B = A; // int f(){ B::x; } + @Test public void testNamespaceAlias() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1803,6 +1870,7 @@ public void testNamespaceAlias() throws Exception { assertInstances(col, x, 3); } + // @Test // public void testBug84250() throws Exception { // assertTrue(((IASTDeclarationStatement) ((IASTCompoundStatement) // ((IASTFunctionDefinition) parse( @@ -1815,6 +1883,7 @@ public void testNamespaceAlias() throws Exception { // int (*p) [2]; // (&p)[0] = 1; // } + @Test public void testBug84250() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1834,6 +1903,7 @@ public void testBug84250() throws Exception { // int (*p) [2]; // (&p)[0] = 1; // } + @Test public void testBug84250b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1849,6 +1919,7 @@ public void testBug84250b() throws Exception { // struct s { double i; } f(void); // struct s f(void){} + @Test public void testBug84266() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1862,6 +1933,7 @@ public void testBug84266() throws Exception { assertSame(s_ref, s_decl); } + @Test public void testBug84266b() throws Exception { IASTTranslationUnit tu = parse("struct s f(void);", CPP); NameCollector col = new NameCollector(); @@ -1887,6 +1959,7 @@ public void testBug84266b() throws Exception { // int x; // { int x = x; } // } + @Test public void testBug84228() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1913,6 +1986,7 @@ public void testBug84228() throws Exception { // A::n = 42; // A b; // } + @Test public void testBug84615() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1931,6 +2005,7 @@ public void testBug84615() throws Exception { assertNotNull(prob); } + @Test public void testBug84371() throws Exception { String code = "int x = ::ABC::DEF::ghi;"; IASTTranslationUnit tu = parse(code, CPP); @@ -1953,6 +2028,7 @@ public void testBug84371() throws Exception { // AB::f(1); // AB::f(`c`); // } + @Test public void testBug84679() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD, false); NameCollector col = new NameCollector(); @@ -1982,6 +2058,7 @@ public void testBug84679() throws Exception { // struct Node * node; // friend struct Glob; // }; + @Test public void testBug84692() throws Exception { // also tests bug 234042. CPPASTNameBase.sAllowRecursionBindings = false; @@ -2004,6 +2081,7 @@ public void testBug84692() throws Exception { // namespace A { using namespace B; int a; } // namespace B { using namespace A; } // void f() { B::a++; } + @Test public void testBug84686() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2028,6 +2106,7 @@ public void testBug84686() throws Exception { // } // return *this; // } + @Test public void testBug84705() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2055,6 +2134,7 @@ public void testBug84705() throws Exception { // class A { void f(); void g() const; }; // void A::f(){ this; } // void A::g() const { *this; } + @Test public void testThis() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -2081,6 +2161,7 @@ public void testThis() throws Exception { assertTrue(((IQualifierType) type).isConst()); } + @Test public void testBug84710() throws Exception { IASTTranslationUnit tu = parse("class T { T(); };", CPP); NameCollector col = new NameCollector(); @@ -2098,6 +2179,7 @@ public void testBug84710() throws Exception { // int main() { // f(parm); // } + @Test public void testArgumentDependantLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2126,6 +2208,7 @@ public void testArgumentDependantLookup() throws Exception { // int main() { // f(a); // } + @Test public void testArgumentDependantLookup_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2155,6 +2238,7 @@ public void testArgumentDependantLookup_b() throws Exception { // A::i; //i2 // j; // } + @Test public void testBug84610() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2181,6 +2265,7 @@ public void testBug84610() throws Exception { // B* pb = new B(); // pb->mutate(); // } + @Test public void testBug84703() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2201,6 +2286,7 @@ public void testBug84703() throws Exception { // void f() { ; // int S::* pm = &S::i; // } + @Test public void testBug84469() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2209,6 +2295,7 @@ public void testBug84469() throws Exception { assertEquals(9, col.size()); } + @Test public void testPointerToMemberType() throws Exception { IASTTranslationUnit tu = parse("struct S; int S::* pm;", CPP); NameCollector col = new NameCollector(); @@ -2232,6 +2319,7 @@ public void testPointerToMemberType() throws Exception { // void f() { // s->*pm = 1; // } + @Test public void testBug_PM_() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2251,6 +2339,7 @@ public void testBug_PM_() throws Exception { // void foo() { // (s->*pm)()->i; // } + @Test public void testBug_PM_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2276,7 +2365,9 @@ public void testBug_PM_b() throws Exception { assertInstances(col, f, 3); } + // @Test // public void testFindTypeBinding_a() throws Exception { + // IASTTranslationUnit tu = parse( // "int x = 5; int y(x);", CPP); // @@ -2298,6 +2389,7 @@ public void testBug_PM_b() throws Exception { // assertTrue(binding instanceof ICPPClassType); // } // + // @Test // public void testFindTypeBinding_b() throws Exception { // IASTTranslationUnit tu = parse( // "struct B; void f() { B * bp; }", CPP); @@ -2321,6 +2413,7 @@ public void testBug_PM_b() throws Exception { // void g() { // B * bp; //1 // } + @Test public void testBug85049() throws Exception { IASTTranslationUnit t = parse(getAboveComment(), CPP); IASTFunctionDefinition g = (IASTFunctionDefinition) t.getDeclarations()[1]; @@ -2335,6 +2428,7 @@ public void testBug85049() throws Exception { // int A::* pm = &A::i; // f(pm); // } + @Test public void testPMConversions() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2361,6 +2455,7 @@ public void testPMConversions() throws Exception { // void g() { // f(pm); // } + @Test public void testPMKoenig_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2387,6 +2482,7 @@ public void testPMKoenig_a() throws Exception { // N::A * a; // f(a->*pm); // } + @Test public void testPMKoenig_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2413,6 +2509,7 @@ public void testPMKoenig_b() throws Exception { // }; // void set(); // class B{}; + @Test public void testFriend() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2436,6 +2533,7 @@ public void testFriend() throws Exception { // friend B; // }; // class B{}; + @Test public void testForwardDeclaredFriend_525645() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -2453,6 +2551,7 @@ public void testForwardDeclaredFriend_525645() throws Exception { // friend void set(); // friend void Other::m(); // }; + @Test public void testFriend_275358() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -2473,6 +2572,7 @@ public void testFriend_275358() throws Exception { // class A { friend class B; friend class B; }; // class B{}; + @Test public void testBug59149() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2494,6 +2594,7 @@ public void testBug59149() throws Exception { // class B { // friend class A::N; // }; + @Test public void testBug59302() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2515,6 +2616,7 @@ public void testBug59302() throws Exception { // class A { // friend class B *helper(); // }; + @Test public void testBug75482() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2538,6 +2640,7 @@ public void testBug75482() throws Exception { // void foo() { // pf = &f; // } + @Test public void testBug45763a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2560,6 +2663,7 @@ public void testBug45763a() throws Exception { // g(&f); // (*pg)(&f); // } + @Test public void testBug45763b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2581,6 +2685,7 @@ public void testBug45763b() throws Exception { // void (* bar ()) (int) { // return &f; // } + @Test public void testBug45763c() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2600,6 +2705,7 @@ public void testBug45763c() throws Exception { // void foo () { // (void (*)(int)) &f; // } + @Test public void testBug45763d() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2617,6 +2723,7 @@ public void testBug45763d() throws Exception { // extern int g; // int g; // void f() { g = 1; } + @Test public void testBug85824() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2638,6 +2745,7 @@ public void testBug85824() throws Exception { // int a4; // a; // } + @Test public void testPrefixLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2669,6 +2777,7 @@ public void testPrefixLookup() throws Exception { // void test(){ // v_; // } + @Test public void testAdditionalNamespaceLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2689,6 +2798,7 @@ public void testAdditionalNamespaceLookup() throws Exception { // static void f(); // void f() {} + @Test public void testIsStatic() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2707,7 +2817,8 @@ public void testIsStatic() throws Exception { // // && __i == 2)) // // return; // // } - // public void testBug85310() throws Exception { + // @Test + // public void testBug85310() throws Exception { // IASTTranslationUnit tu = parse(getAboveComment(), CPP); // IASTFunctionDefinition f = (IASTFunctionDefinition) // tu.getDeclarations()[0]; @@ -2725,6 +2836,7 @@ public void testIsStatic() throws Exception { // void g() { // B* pb = new (p) D1; // } + @Test public void testBug86267() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(true); @@ -2755,6 +2867,7 @@ public void testBug86267() throws Exception { // } // return *this; // } + @Test public void testBug86269() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2782,6 +2895,7 @@ public void testBug86269() throws Exception { // printf(p); // printf("abc"); // } + @Test public void testBug86279() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2801,6 +2915,7 @@ public void testBug86279() throws Exception { // void h() { // g(a); // } + @Test public void testBug86346() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2813,6 +2928,7 @@ public void testBug86346() throws Exception { assertInstances(col, g, 2); } + @Test public void testBug86288() throws Exception { String code = "int *foo(int *b) { return (int *)(b); }"; IASTTranslationUnit tu = parse(code, CPP); @@ -2827,6 +2943,7 @@ public void testBug86288() throws Exception { // }; // int (B::*pb)() = &B::f; // } + @Test public void testBug84476() throws Exception { String code = getAboveComment(); IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(code, CPP).getDeclarations()[0]; @@ -2845,6 +2962,7 @@ public void testBug84476() throws Exception { // } // A(int) {} // }; + @Test public void testBug86336() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPClassType clazz = bh.assertNonProblem("A {", "A", ICPPClassType.class); @@ -2864,6 +2982,7 @@ public void testBug86336() throws Exception { // void foo() { // int S::* pm = &S::i; // } + @Test public void testBug86306() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2889,6 +3008,7 @@ public void testBug86306() throws Exception { // using A::f; // illformed // using A::X; // illformed // }; + @Test public void testBug86372() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2902,6 +3022,7 @@ public void testBug86372() throws Exception { // a[i] = 1; // int j = i; // } + @Test public void testBug86319() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2925,6 +3046,7 @@ public void testBug86319() throws Exception { // p->x.i; // p->x.j; // } + @Test public void testBug86350() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2951,6 +3073,7 @@ public void testBug86350() throws Exception { // i = 0; // } // } + @Test public void testBug84478() throws Exception { IASTFunctionDefinition foo = (IASTFunctionDefinition) parse(getAboveComment(), CPP).getDeclarations()[0]; ICPPASTWhileStatement whileStatement = (ICPPASTWhileStatement) ((IASTCompoundStatement) foo.getBody()) @@ -2964,6 +3087,7 @@ public void testBug84478() throws Exception { // { enum { x = x }; } // } // enum { RED }; + @Test public void testBug86353() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2997,6 +3121,7 @@ public void testBug86353() throws Exception { // typeid(d1) == typeid(d2); // typeid(D) == typeid(d2); // } + @Test public void testBug86274() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3018,6 +3143,7 @@ public void testBug86274() throws Exception { // point(1); // point(); // } + @Test public void testBug86546() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3036,6 +3162,7 @@ public void testBug86546() throws Exception { // void g() { i++; } // } // } + @Test public void testBug86358a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3056,6 +3183,7 @@ public void testBug86358a() throws Exception { // namespace V { // } // } + @Test public void testBug86358b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3086,6 +3214,7 @@ public void testBug86358b() throws Exception { // void f(int) { f('c'); } // void g(int) { g('c'); } // }; + @Test public void test86371() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3118,6 +3247,7 @@ public void test86371() throws Exception { // namespace CWVLN = Company_with_veryblahblah; // namespace CWVLN = Company_with_veryblahblah; // namespace CWVLN = CWVLN; + @Test public void testBug86369() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3159,6 +3289,7 @@ public void testBug86369() throws Exception { // void f(int); // } // using A::f; + @Test public void testBug86470a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3198,6 +3329,7 @@ public void testBug86470a() throws Exception { // using B::f; // f('c'); // } + @Test public void testBug86470b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3217,6 +3349,7 @@ public void testBug86470b() throws Exception { // g('a'); // struct g gg; // } + @Test public void testBug86470c() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3251,6 +3384,7 @@ public void testBug86470c() throws Exception { // x = 1; // struct x xx; // } + @Test public void testBug86470d() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3290,6 +3424,7 @@ public void testBug86470d() throws Exception { // using A::f; // f(3.5); // } + @Test public void testBug86470e() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3320,6 +3455,7 @@ public void testBug86470e() throws Exception { // void f(B* p) { // p->i = 1; // } + @Test public void testBug86678() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3340,6 +3476,7 @@ public void testBug86678() throws Exception { // printf("hello"); // printf("a=%d b=%d", a, b); // } + @Test public void testBug86543() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3353,6 +3490,7 @@ public void testBug86543() throws Exception { // int m = (a > b) ? a : b; // return (m > c) ? m : c; // } + @Test public void testBug86554() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3377,6 +3515,7 @@ public void testBug86554() throws Exception { // struct X { static int g(); }; // struct Y : X { static int i ; }; // int Y::i = g(); + @Test public void testBug86621() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3414,6 +3553,7 @@ public void testBug86621() throws Exception { // y++; // g(); // } + @Test public void testBug86649() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3446,6 +3586,7 @@ public void testBug86649() throws Exception { // int c; // C() : c(0) { } // }; + @Test public void testBug86827() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3470,6 +3611,7 @@ public void testBug86827() throws Exception { // int v2; // } // } + @Test public void testFind_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3498,6 +3640,7 @@ public void testFind_a() throws Exception { // }; // void B::f() { // } + @Test public void testFind_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3530,6 +3673,7 @@ public void testFind_b() throws Exception { // void f(char); // using A::f; // } + @Test public void testFind_c() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3568,6 +3712,7 @@ public void testFind_c() throws Exception { // using namespace A; // using namespace C; // } + @Test public void testFind_d() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3596,6 +3741,7 @@ public void testFind_d() throws Exception { // B(); // void bf(); // }; + @Test public void testFind_185408() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3629,6 +3775,7 @@ public void testFind_185408() throws Exception { // int b; // void fb(); // }; + @Test public void testImplicitMethods() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3687,6 +3834,7 @@ public void testImplicitMethods() throws Exception { assertSame(result[9], A_implicit[3]); } + @Test public void testBug87424() throws Exception { IASTTranslationUnit tu = parse("int * __restrict x;", CPP, ScannerKind.GNU); NameCollector col = new NameCollector(); @@ -3707,6 +3855,7 @@ public void testBug87424() throws Exception { assertTrue(((ICPPPointerToMemberType) t).isRestrict()); } + @Test public void testBug87705() throws Exception { IASTTranslationUnit tu = parse("class A { friend class B::C; };", CPP, ScannerKind.GNU); NameCollector col = new NameCollector(); @@ -3718,6 +3867,7 @@ public void testBug87705() throws Exception { assertEquals(C.getID(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND); } + @Test public void testBug88459() throws Exception { IASTTranslationUnit tu = parse("int f(); ", CPP); NameCollector col = new NameCollector(); @@ -3727,6 +3877,7 @@ public void testBug88459() throws Exception { assertFalse(f.isStatic()); } + @Test public void testBug88501a() throws Exception { IASTTranslationUnit tu = parse("void f(); void f(int); struct f;", CPP); NameCollector col = new NameCollector(); @@ -3737,7 +3888,9 @@ public void testBug88501a() throws Exception { assertTrue(col.getName(3).resolveBinding() instanceof ICPPClassType); } + // @Test // public void testBug8342a() throws Exception { + // IASTTranslationUnit tu = parse("int a; int a;", CPP); // // NameCollector col = new NameCollector(); @@ -3747,6 +3900,7 @@ public void testBug88501a() throws Exception { // IProblemBinding p = (IProblemBinding) col.getName(1).resolveBinding(); // assertEquals(p.getID(), IProblemBinding.SEMANTIC_INVALID_REDEFINITION); // } + @Test public void testBug8342b() throws Exception { IASTTranslationUnit tu = parse("extern int a; extern char a;", CPP); NameCollector col = new NameCollector(); @@ -3762,6 +3916,7 @@ public void testBug8342b() throws Exception { // void f() { // B::i; // } + @Test public void testNamespaceAlias_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3792,6 +3947,7 @@ public void testNamespaceAlias_b() throws Exception { // void test() { // MACRO; // } + @Test public void testNamespaceAliasInMacroExpansion_506668() throws Exception { parseAndCheckBindings(); } @@ -3800,6 +3956,7 @@ public void testNamespaceAliasInMacroExpansion_506668() throws Exception { // class B : public A { // B () : A() {} // }; + @Test public void testBug89539() throws Exception { String content = getAboveComment(); IASTTranslationUnit tu = parse(content, CPP); @@ -3825,6 +3982,7 @@ public void testBug89539() throws Exception { // A * a; // }; // class A; + @Test public void testBug89851() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3836,6 +3994,7 @@ public void testBug89851() throws Exception { assertTrue(col.getName(3).resolveBinding() instanceof ICPPClassType); } + @Test public void testBug89828() throws Exception { IASTTranslationUnit tu = parse("class B * b; void f(); void f(int);", CPP); NameCollector col = new NameCollector(); @@ -3862,6 +4021,7 @@ public void testBug89828() throws Exception { // f(A::t1); // } // }; + @Test public void testBug90039() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3877,6 +4037,7 @@ public void testBug90039() throws Exception { // void f(void) { // enum { one }; // } + @Test public void testBug90039b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3893,6 +4054,7 @@ public void testBug90039b() throws Exception { // operator int(); // char& operator[](unsigned int); // }; + @Test public void testOperatorConversionNames() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3917,6 +4079,7 @@ public void testOperatorConversionNames() throws Exception { // X::operator int() { } // template class X { operator int(); }; // template X::operator int() { } + @Test public void testBug36769B() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3959,6 +4122,7 @@ public void testBug36769B() throws Exception { assertNotNull(((ICPPASTConversionName) int4).getTypeId()); } + @Test public void testBug88662() throws Exception { IASTTranslationUnit tu = parse("int foo() { return int();}", CPP); IASTReturnStatement returnStatement = (IASTReturnStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu @@ -3969,6 +4133,7 @@ public void testBug88662() throws Exception { assertEquals(expression.getSimpleType(), ICPPASTSimpleTypeConstructorExpression.t_int); } + @Test public void testBug90498a() throws Exception { IASTTranslationUnit tu = parse("typedef int INT;\ntypedef INT (FOO) (INT);", CPP); @@ -3984,6 +4149,7 @@ public void testBug90498a() throws Exception { assertEquals(nested.getName().toString(), "FOO"); } + @Test public void testBug90498b() throws Exception { IASTTranslationUnit tu = parse("int (* foo) (int) (0);", CPP); @@ -4007,6 +4173,7 @@ public void testBug90498b() throws Exception { // typeid(d1) == typeid(d2); // typeid(D) == typeid(d2); // } + @Test public void testBug866274() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTFunctionDefinition foo = (IASTFunctionDefinition) tu.getDeclarations()[3]; @@ -4030,6 +4197,7 @@ public void testBug866274() throws Exception { } } + @Test public void testTypedefFunction() throws Exception { IASTTranslationUnit tu = parse("typedef int foo (int);", CPP); NameCollector col = new NameCollector(); @@ -4046,6 +4214,7 @@ public void testTypedefFunction() throws Exception { // typedef A B; // // B a = B(1); + @Test public void testTypedefConstructorCall() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPConstructor ctor = bh.assertNonProblem("A(int x)", "A", ICPPConstructor.class); @@ -4062,6 +4231,7 @@ public void testTypedefConstructorCall() throws Exception { // void foo(){ // f((1, 2)); // } + @Test public void testBug90616() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4072,6 +4242,7 @@ public void testBug90616() throws Exception { assertSame(f1, f2); } + @Test public void testBug90603() throws Exception { IASTTranslationUnit tu = parse("class X { void f(){} };", CPP); NameCollector col = new NameCollector(); @@ -4095,6 +4266,7 @@ public void testBug90603() throws Exception { // class X { }; // X x; // class X { }; + @Test public void testBug90662() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4153,6 +4325,7 @@ public void testBug90662() throws Exception { // const C& operator <(const C&); // const C& operator>(const C&); // }; + @Test public void testOperatorNames() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4206,6 +4379,7 @@ public void testOperatorNames() throws Exception { // struct C { // auto operator<=>(const C&); // }; + @Test public void testThreeWayComparisonOperatorName() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STDCPP20); NameCollector col = new NameCollector(); @@ -4228,6 +4402,7 @@ public void testThreeWayComparisonOperatorName() throws Exception { // static constexpr auto greater01 = greater(0, 1); // static constexpr auto greater00 = greater(0, 0); // static constexpr auto greater10 = greater(1, 0); + @Test public void testThreeWayComparisonSimpleCase() throws Exception { BindingAssertionHelper helper = getAssertionHelper(CPP, ScannerKind.STDCPP20); helper.assertVariableValue("less01", 1); @@ -4252,6 +4427,7 @@ public void testThreeWayComparisonSimpleCase() throws Exception { // }; // // constexpr auto value = V1 | V2; + @Test public void testBinaryOperatorOverloadTemplate() throws Exception { BindingAssertionHelper helper = getAssertionHelper(CPP); helper.assertVariableValue("value", 42); @@ -4265,6 +4441,7 @@ public void testBinaryOperatorOverloadTemplate() throws Exception { // typedef char I; // typedef I I; // }; + @Test public void testBug90623() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4298,6 +4475,7 @@ public void testBug90623() throws Exception { // typedef int I; // void f11(I i); // void main(){ f a; } + @Test public void testBug90623b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4317,6 +4495,7 @@ public void testBug90623b() throws Exception { // }; // Y y; // X* x = new X(y); + @Test public void testBug90654a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(true); @@ -4333,6 +4512,7 @@ public void testBug90654a() throws Exception { // int f(int); // int f(float); // int x = f(a); + @Test public void testBug90654b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4351,6 +4531,7 @@ public void testBug90654b() throws Exception { // this->A::operator=(s); // return *this; // } + @Test public void testBug90653() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4372,6 +4553,7 @@ public void testBug90653() throws Exception { // void foo() { // f("test"); // } + @Test public void testBug86618() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4386,6 +4568,7 @@ public void testBug86618() throws Exception { // void foo () { // f(g) ; // } + @Test public void testBug45129() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4411,6 +4594,7 @@ public void testBug45129() throws Exception { // ABC::DEF * var; // ABC::GHI * value; // } + @Test public void testAmbiguousStatements() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTDeclaration[] declarations = tu.getDeclarations(); @@ -4425,6 +4609,7 @@ public void testAmbiguousStatements() throws Exception { // union { int a; char* p; }; // a = 1; // } + @Test public void testBug86639() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4439,6 +4624,7 @@ public void testBug86639() throws Exception { // int aa1, aa2; // a; // } + @Test public void testBug80940() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4463,6 +4649,7 @@ public void testBug80940() throws Exception { // const Ex * e; // e->d(); // } + @Test public void testBug77024() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4490,6 +4677,7 @@ public void testBug77024() throws Exception { // Point() : xCoord(0) {} // int xCoord; // }; + @Test public void testBug91773() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4500,6 +4688,7 @@ public void testBug91773() throws Exception { assertSame(x, x2); } + @Test public void testBug90648() throws ParserException { IASTTranslationUnit tu = parse("int f() { int (&ra)[3] = a; }", CPP); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -4513,6 +4702,7 @@ public void testBug90648() throws ParserException { assertTrue(declarators[0] instanceof IASTArrayDeclarator); } + @Test public void testBug92980() throws Exception { String code = "struct A { A(); A(const A&) throw(1); ~A() throw(X); };"; parse(code, CPP, ScannerKind.GNU, false); @@ -4520,6 +4710,7 @@ public void testBug92980() throws Exception { // class Dummy { int v(); int d; }; // void Dummy::v(int){ d++; } + @Test public void testBug92882() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4538,6 +4729,7 @@ public void testBug92882() throws Exception { // f(3); // f(); // } + @Test public void testBug86547() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4547,6 +4739,7 @@ public void testBug86547() throws Exception { assertInstances(col, f1, 5); } + @Test public void testBug90647() throws Exception { parse("char msg[] = \"Syntax error on line %s\\n\";", CPP); } @@ -4564,6 +4757,7 @@ public void testBug90647() throws Exception { // int k; // k = sum; // } + @Test public void testBug82766() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4577,6 +4771,7 @@ public void testBug82766() throws Exception { // char *c; // l |= ((unsigned long)(*((c)++)))<<24; // } + @Test public void testBug77385() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4584,6 +4779,7 @@ public void testBug77385() throws Exception { assertNoProblemBindings(col); } + @Test public void testBug83997() throws Exception { IASTTranslationUnit tu = parse("namespace { int x; }", CPP); NameCollector col = new NameCollector(); @@ -4591,6 +4787,7 @@ public void testBug83997() throws Exception { assertNoProblemBindings(col); } + @Test public void testBug85786() throws Exception { IASTTranslationUnit tu = parse("void f(int); void foo () { void * p = &f; ((void (*) (int)) p) (1); }", ParserLanguage.C); @@ -4604,6 +4801,7 @@ public void testBug85786() throws Exception { // static int arr[ n ]; // }; // int C::arr[n]; + @Test public void testBug90610() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4629,6 +4827,7 @@ public void testBug90610() throws Exception { // int X::y = 1; // int (*g(int))(int); // int (*pf)(int); + @Test public void testDeclDefn() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4655,6 +4854,7 @@ public void testDeclDefn() throws Exception { // int f(int); // int (&rfi)(int) = f; // int (&rfd)(double) = f; + @Test public void testBug95200() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4667,6 +4867,7 @@ public void testBug95200() throws Exception { assertSame(col.getName(9).resolveBinding(), f1); } + @Test public void testBug95425() throws Exception { IASTTranslationUnit tu = parse("class A { A(); };", CPP); NameCollector col = new NameCollector(); @@ -4696,6 +4897,7 @@ public void testBug95425() throws Exception { // char x[100]; // f(x); // } + @Test public void testBug95461() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4710,6 +4912,7 @@ public void testBug95461() throws Exception { // A * b = 0; // A & c = 0; // } + @Test public void testAmbiguity() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTSimpleDeclaration A = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -4738,6 +4941,7 @@ public void testAmbiguity() throws Exception { // F f; // f.A::a = 1; // } + @Test public void testBug84696() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4761,6 +4965,7 @@ public void testBug84696() throws Exception { // int a; // }; // int X:: * pmi = &X::a; + @Test public void testBasicPointerToMember() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); assertEquals(tu.getDeclarations().length, 2); @@ -4779,6 +4984,7 @@ public void testBasicPointerToMember() throws Exception { // void foo() { // (waldo()->*true).meow(); // Method 'meow' could not be resolved // } + @Test public void testOverloadedPointerToMemberOperator_488611() throws Exception { parseAndCheckBindings(); } @@ -4788,6 +4994,7 @@ public void testOverloadedPointerToMemberOperator_488611() throws Exception { // void foo(D* dp) { // B* bp = dynamic_cast(dp); // } + @Test public void testBug84466() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); ICPPASTCastExpression dynamic_cast = (ICPPASTCastExpression) ((IASTEqualsInitializer) ((IASTSimpleDeclaration) ((IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu @@ -4797,6 +5004,7 @@ public void testBug84466() throws Exception { assertEquals(dynamic_cast.getOperator(), ICPPASTCastExpression.op_dynamic_cast); } + @Test public void testBug88338_CPP() throws Exception { IASTTranslationUnit tu = parse("struct A; struct A* a;", CPP); NameCollector col = new NameCollector(); @@ -4815,6 +5023,7 @@ public void testBug88338_CPP() throws Exception { assertFalse(col.getName(0).isReference()); } + @Test public void testPointerToFunction_CPP() throws Exception { IASTTranslationUnit tu = parse("int (*pfi)();", CPP); assertEquals(tu.getDeclarations().length, 1); @@ -4831,6 +5040,7 @@ public void testPointerToFunction_CPP() throws Exception { // X a[10]; // a[0].bar; // } + @Test public void testBug95484() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4844,6 +5054,7 @@ public void testBug95484() throws Exception { // void f(const char * const * argv){ // strcmp(*argv); // } + @Test public void testBug95419() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4861,6 +5072,7 @@ public void testBug95419() throws Exception { // public: Sub(Other *); // }; // Sub::Sub(Other * b) : Base(b) {} + @Test public void testBug95673() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); @@ -4875,6 +5087,7 @@ public void testBug95673() throws Exception { // mem(x, "FUNC"); // mem(x + offset, "FUNC2"); // } + @Test public void testBug95768() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4892,6 +5105,7 @@ public void testBug95768() throws Exception { // int Foo::import(){ // trace(this); // } + @Test public void testBug95741() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4908,6 +5122,7 @@ public void testBug95741() throws Exception { // RTCharacter::operator char(void)const { // return value; // } + @Test public void testBug95692() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4922,6 +5137,7 @@ public void testBug95692() throws Exception { // str(0); // str(00); str(0x0); // } + @Test public void testBug95734() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4939,6 +5155,7 @@ public void testBug95734() throws Exception { // str(1.2); // str(ONE); str(p); // } + @Test public void testBug95734b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -4954,6 +5171,7 @@ public void testBug95734b() throws Exception { // char * value; // ::operator delete(value); // } + @Test public void testBug95786() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -4971,6 +5189,7 @@ public void testBug95786() throws Exception { // catch (...) // { // } + @Test public void testBug86868() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); assertEquals(tu.getDeclarations().length, 1); @@ -4979,6 +5198,7 @@ public void testBug86868() throws Exception { // void f(int t){ // int s (t); // } + @Test public void testBug94779() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTDeclarationStatement ds = (IASTDeclarationStatement) ((IASTCompoundStatement) ((IASTFunctionDefinition) tu @@ -4989,6 +5209,7 @@ public void testBug94779() throws Exception { // int t= 0; // int s (t); + @Test public void testBug211756() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTSimpleDeclaration sd = (IASTSimpleDeclaration) (tu.getDeclarations()[1]); @@ -5003,6 +5224,7 @@ public void testBug211756() throws Exception { // ci->state; // (ci - 1)->state; // } + @Test public void testBug95714() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5015,6 +5237,7 @@ public void testBug95714() throws Exception { // float _Complex x; // double _Complex y; + @Test public void testBug95757() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); IASTDeclaration[] decls = tu.getDeclarations(); @@ -5034,6 +5257,7 @@ public void testBug95757() throws Exception { // void f(){ // A::i++; // } + @Test public void testTypedefQualified() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5051,6 +5275,7 @@ public void testTypedefQualified() throws Exception { // int b(f()); // return a+b; // } + @Test public void testBug86849() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5063,6 +5288,7 @@ public void testBug86849() throws Exception { // void f(A * a) { // copy(a); // } + @Test public void testBug96655() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5072,6 +5298,7 @@ public void testBug96655() throws Exception { assertSame(copy, col.getName(7).resolveBinding()); } + @Test public void testBug96678() throws Exception { parse("int x; // comment \r\n", CPP, ScannerKind.STD, true); } @@ -5081,6 +5308,7 @@ public void testBug96678() throws Exception { // void f() { // copy(new A()); // } + @Test public void testNewExpressionType() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5093,6 +5321,7 @@ public void testNewExpressionType() throws Exception { // class A { // A(int i = 0); // }; + @Test public void testDefaultConstructor() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5116,6 +5345,7 @@ public void testDefaultConstructor() throws Exception { // b->foo; // b[0].foo; // } + @Test public void testBug91707() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5133,6 +5363,7 @@ public void testBug91707() throws Exception { // class C {}; // }; // class A::B{}; + @Test public void testBug92425() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5152,6 +5383,7 @@ public void testBug92425() throws Exception { // struct F {} f; // void f(int a) {} // } + @Test public void testBug92425b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5167,12 +5399,14 @@ public void testBug92425b() throws Exception { // A< B< C< D< E< F< G< H > > > > > > > a; // int A::B::* b; + @Test public void testBug98704() throws Exception { parse(getAboveComment(), CPP); } // void f(); // void f(void) {} + @Test public void testBug_AIOOBE() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5187,6 +5421,7 @@ public void testBug_AIOOBE() throws Exception { // void f(const int); // void f(int); // void g() { f(1); } + @Test public void testRankingQualificationConversions_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5198,6 +5433,7 @@ public void testRankingQualificationConversions_a() throws Exception { // void f(const volatile int); // void f(const int); // void g() { f(1); } + @Test public void testRankingQualificationConversions_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5225,6 +5461,7 @@ public void testRankingQualificationConversions_b() throws Exception { // i(&ca); // i(const int *) // i(&a); // i(int * const &) // } + @Test public void testRankingQualificationConversions_c() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5270,6 +5507,7 @@ public void testRankingQualificationConversions_c() throws Exception { // void A::f(){} // } // } + @Test public void testBug98818() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5297,6 +5535,7 @@ public void testBug98818() throws Exception { // A a; // a.B.i; a.C.j; // } + @Test public void testAnonymousStructures() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -5308,6 +5547,7 @@ public void testAnonymousStructures() throws Exception { assertSame(j, col.getName(5).resolveBinding()); } + @Test public void testBug99262() throws Exception { parse("void foo() {void *f; f=__null;}", CPP, ScannerKind.GNU, true); } @@ -5317,11 +5557,13 @@ public void testBug99262() throws Exception { // void f2() { // f1(__null); // } + @Test public void testBug240567() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("f1(__null", 2, ICPPFunction.class); } + @Test public void testBug100408() throws Exception { IASTTranslationUnit tu = parse("int foo() { int x=1; (x)*3; }", CPP); NameCollector col = new NameCollector(); @@ -5329,6 +5571,7 @@ public void testBug100408() throws Exception { assertNoProblemBindings(col); } + @Test public void testBug84478c() throws Exception { IASTTranslationUnit tu = parse("void foo() { switch(int x = 4) { case 4: x++; break; default: break;} }", CPP); NameCollector col = new NameCollector(); @@ -5337,6 +5580,7 @@ public void testBug84478c() throws Exception { assertSame(col.getName(1).resolveBinding(), col.getName(2).resolveBinding()); } + @Test public void testBug84478d() throws Exception { IASTTranslationUnit tu = parse("void foo() { for(int i = 0; int j = 0; ++i) {} }", CPP); NameCollector col = new NameCollector(); @@ -5353,6 +5597,7 @@ public void testBug84478d() throws Exception { // a++; b++; // } // } + @Test public void testBug84478b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5377,6 +5622,7 @@ public void testBug84478b() throws Exception { // void f(char** p) { // free(p); // } + @Test public void testBug100415() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5397,6 +5643,7 @@ public void testBug100415() throws Exception { // friend class X; // }; // } + @Test public void testBug86688() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5412,6 +5659,7 @@ public void testBug86688() throws Exception { // int m::f(); // }; // int m::f(){} + @Test public void testBug100403() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5431,6 +5679,7 @@ public void testBug100403() throws Exception { // friend void A::f1(AT); // friend void A::f2(BT); // }; + @Test public void testBug90609() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5454,6 +5703,7 @@ public void testBug90609() throws Exception { // e->blah; // } // } + @Test public void testBug103281() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5466,6 +5716,7 @@ public void testBug103281() throws Exception { assertSame(blah, col.getName(6).resolveBinding()); } + @Test public void testBug78800() throws Exception { parseAndCheckBindings( "class Matrix { public: Matrix & operator *(Matrix &); }; Matrix rotate, translate; Matrix transform = rotate * translate;"); @@ -5478,6 +5729,7 @@ public void testBug78800() throws Exception { // void X::foo() { // i; // } + @Test public void test10_2s3b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -5495,6 +5747,7 @@ public void test10_2s3b() throws Exception { // int f() { // int x = 4; while(x < 10) blah: ++x; // } + @Test public void testBug1043290() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition fd = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -5511,6 +5764,7 @@ public void testBug1043290() throws Exception { // do { ++i; } while(i < 10); // return 0; // } + @Test public void testBug104800() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0]; @@ -5518,6 +5772,7 @@ public void testBug104800() throws Exception { assertEquals(body.getStatements().length, 3); } + @Test public void testBug107150() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#define FUNC_PROTOTYPE_PARAMS(list) list\r\n"); @@ -5551,6 +5806,7 @@ public void testBug107150() throws Exception { // int FooClass::foo() { // return 0; // } + @Test public void testBug108202() throws Exception { parse(getAboveComment(), CPP, ScannerKind.GNU, true); } @@ -5561,6 +5817,7 @@ public void testBug108202() throws Exception { // static int MyClass::static_field; // }; // int MyClass::static_field; + @Test public void testBug174791() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -5599,6 +5856,7 @@ public void testBug174791() throws Exception { // } // void nsSplit::a() { // } + @Test public void testBug180979() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -5615,6 +5873,7 @@ public void testBug180979() throws Exception { // #define _GLIBCXX_BEGIN_NAMESPACE(X) namespace X _GLIBCXX_VISIBILITY(default) { // _GLIBCXX_BEGIN_NAMESPACE(std) // } // end the namespace + @Test public void testBug195701() throws Exception { parse(getAboveComment(), CPP, ScannerKind.GNU, true); } @@ -5626,6 +5885,7 @@ public void testBug195701() throws Exception { // double operator*(double); // using A::operator*; // }; + @Test public void testBug178059() throws Exception { parse(getAboveComment(), CPP, ScannerKind.GNU, true); } @@ -5633,6 +5893,7 @@ public void testBug178059() throws Exception { // void foo (void *p) throw () ; // void bar (void *p) __attribute__ ((__nonnull__(1))); // void zot (void *p) throw () __attribute__ ((__nonnull__(1))); + @Test public void testBug179712() throws Exception { parse(getAboveComment(), CPP, ScannerKind.GNU, true); } @@ -5667,6 +5928,7 @@ public void testBug179712() throws Exception { // problem4(ptm); // problem5(ptm); // } + @Test public void testBug214335() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -5696,6 +5958,7 @@ public void testBug214335() throws Exception { // } // outer::foo x; // outer::inner::foo y; + @Test public void testAttributeInUsingDirective_351228() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -5721,6 +5984,7 @@ public void testAttributeInUsingDirective_351228() throws Exception { // fs(); // fs(1); // } + @Test public void testReferencesOfUsingDecls() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -5803,6 +6067,7 @@ public void testReferencesOfUsingDecls() throws Exception { // void O::I::f() { // a=0; // } + @Test public void testUsingDirectiveWithNestedClass_209582() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -5822,6 +6087,7 @@ public void testUsingDirectiveWithNestedClass_209582() throws Exception { // Test foo2 (bar, pBar); // Test foo3 (&bar); // } + @Test public void testCastAmbiguity_211756() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -5836,6 +6102,7 @@ public void testCastAmbiguity_211756() throws Exception { // if (relayIndex < 0 || relayIndex > numRelays) // return 0; // } + @Test public void testTemplateIDAmbiguity_104706() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -5859,6 +6126,7 @@ public void testTemplateIDAmbiguity_104706() throws Exception { // (base::has_trivial_copy::value && // base::has_trivial_destructor::value)> // realloc_ok; + @Test public void testTemplateIDAmbiguity_228118() throws Exception { parse(getAboveComment(), CPP); } @@ -5874,6 +6142,7 @@ public void testTemplateIDAmbiguity_228118() throws Exception { // func(qualified); // func(unqualified); // } + @Test public void testScopeOfUsingDelegates_219424() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -5889,6 +6158,7 @@ public void testScopeOfUsingDelegates_219424() throws Exception { // void Test::member1(){ // member2(); // } + @Test public void testQualifiedMemberDeclaration_222026() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5937,6 +6207,7 @@ public void testQualifiedMemberDeclaration_222026() throws Exception { // void Test::member1(){ // member2(); // } + @Test public void testQualifiedMemberDeclarationInNamespace_222026() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -5979,6 +6250,7 @@ public void testQualifiedMemberDeclarationInNamespace_222026() throws Exception } // namespace ns { typedef int ns::TINT; } // illegal, still no CCE is expected. + @Test public void testQualifiedTypedefs_222093() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IBinding td = bh.assertProblem("TINT", 4); @@ -5991,11 +6263,13 @@ public void testQualifiedTypedefs_222093() throws Exception { // if (a > b) { // } // } + @Test public void testResettingTemplateIdScopesStack_223777() throws Exception { parseAndCheckBindings(getAboveComment()); } // long x= 10L; + @Test public void testLongLiteral_225534() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); IASTDeclarator decltor = ((IASTSimpleDeclaration) tu.getDeclarations()[0]).getDeclarators()[0]; @@ -6011,6 +6285,7 @@ public void testLongLiteral_225534() throws Exception { // short sh(0); // long l(0L); // long long ll(0LL); + @Test public void testInitializeUnsigned_245070() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -6063,6 +6338,7 @@ public void testInitializeUnsigned_245070() throws Exception { // foo/*k1*/(11.1L); // foo/*k2*/(11.1E1L); // } + @Test public void testLiteralsViaOverloads_225534() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); char[] cs = { 'a', 'b', 'e', 'f', 'g', 'h', 'i', 'j', 'k' }; @@ -6070,7 +6346,7 @@ public void testLiteralsViaOverloads_225534() throws Exception { for (int i = 1; i < (c < 'i' ? 4 : 3); i++) { ICPPFunction def = ba.assertNonProblem("foo/*_" + c + "*/", 3, ICPPFunction.class); ICPPFunction ref = ba.assertNonProblem("foo/*" + c + "" + i + "*/", 3, ICPPFunction.class); - assertSame("function ref: " + c + "" + i, def, ref); + assertSame(def, ref, "function ref: " + c + "" + i); } } } @@ -6096,6 +6372,7 @@ public void testLiteralsViaOverloads_225534() throws Exception { // SecondLevelProxy p2; // p2->doA(); // } + @Test public void testRecursiveUserDefinedFieldAccess_205964() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -6107,6 +6384,7 @@ public void testRecursiveUserDefinedFieldAccess_205964() throws Exception { // using ns::A; // // class B: public A {}; + @Test public void testBug235196() throws Exception { parseAndCheckBindings(getAboveComment()); } @@ -6123,6 +6401,7 @@ public void testBug235196() throws Exception { // X::~X() {} // X::operator int() {} // X::xtint(a); // 2 + @Test public void testEmptyDeclSpecifier() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("X {", 1, ICPPClassType.class); @@ -6158,6 +6437,7 @@ public void testEmptyDeclSpecifier() throws Exception { // new (T[f][f]); // new (p) (T[f][f]); // }; + @Test public void testNewPlacement() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment()); IASTFunctionDefinition fdef = getDeclaration(tu, 3); @@ -6185,6 +6465,7 @@ public void testNewPlacement() throws Exception { // void test() {} // + // } + @Test public void testTrailingSyntaxErrorInNamespace() throws Exception { final String comment = getAboveComment(); IASTTranslationUnit tu = parse(comment, CPP, ScannerKind.STD, false); @@ -6198,6 +6479,7 @@ public void testTrailingSyntaxErrorInNamespace() throws Exception { // void test() {} // + // } + @Test public void testTrailingSyntaxErrorInLinkageSpec() throws Exception { final String comment = getAboveComment(); IASTTranslationUnit tu = parse(comment, CPP, ScannerKind.STD, false); @@ -6209,6 +6491,7 @@ public void testTrailingSyntaxErrorInLinkageSpec() throws Exception { // class C; // void func(void (C::*m)(int) const); + @Test public void test233889_a() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPFunction func = bh.assertNonProblem("func(", 4, ICPPFunction.class); @@ -6231,6 +6514,7 @@ public void test233889_a() throws Exception { // func(&C::m1); // func(&C::m2); // } + @Test public void testBug233889_b() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPFunction fn1 = bh.assertNonProblem("func(&C::m1", 4, ICPPFunction.class); @@ -6252,6 +6536,7 @@ public void testBug233889_b() throws Exception { // void member3() volatile { foo(this);/*3*/ } // void member4() const volatile { foo(this);/*4*/ } // }; + @Test public void testThisType() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPFunction pt1 = ba.assertNonProblem("foo(this);/*1*/", 3, ICPPFunction.class); @@ -6284,6 +6569,7 @@ public void testThisType() throws Exception { // A* a2= new A(); // a2->foo();/*2*/ // } + @Test public void testMemberAccessOperator_a() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("foo();/*1*/", 3); @@ -6307,6 +6593,7 @@ public void testMemberAccessOperator_a() throws Exception { // B* b2= new B(); // b2->foo();/*2*/ // } + @Test public void testMemberAccessOperator_b() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPMethod m1 = ba.assertNonProblem("foo();/*1*/", 3, ICPPMethod.class); @@ -6323,6 +6610,7 @@ public void testMemberAccessOperator_b() throws Exception { // C c; // c->foo();/**/ // refers to A::foo // } + @Test public void testMemberAccessOperator_c() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("foo();/**/", 3); @@ -6336,6 +6624,7 @@ public void testMemberAccessOperator_c() throws Exception { // C c; // c->foo();/**/ // expect problem - foo is not in B // } + @Test public void testMemberAccessOperator_d() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("foo();/**/", 3); @@ -6352,6 +6641,7 @@ public void testMemberAccessOperator_d() throws Exception { // C2 c; // c->foo();/**/ // refers to A::foo // } + @Test public void testMemberAccessOperator_e() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("foo();/**/", 3); @@ -6363,6 +6653,7 @@ public void testMemberAccessOperator_e() throws Exception { // typeid(int).name(); // typeid(s).name(); // } + @Test public void testTypeid_209578() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6380,6 +6671,7 @@ public void testTypeid_209578() throws Exception { // f3(r); // f4(s); // } + @Test public void testArrayToPointerConversion() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("f1(p)", 2, ICPPFunction.class); @@ -6400,6 +6692,7 @@ public void testArrayToPointerConversion() throws Exception { // test(y); // test(z); // } + @Test public void testArrayToPtrConversionForTypedefs_239931() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6414,6 +6707,7 @@ public void testArrayToPtrConversionForTypedefs_239931() throws Exception { // test2(x); // test3(x); // } + @Test public void testAdjustmentOfParameterTypes_239975() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6428,11 +6722,13 @@ public void testAdjustmentOfParameterTypes_239975() throws Exception { // ptr2mem= reinterpret_cast(&A::m); // ptr2mem= (void (A::*)(int))(0); // } + @Test public void testTypeIdForPtrToMember_242197() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } // void restrict(); + @Test public void testRestrictIsNoCPPKeyword_228826() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP, ScannerKind.STD); @@ -6442,6 +6738,7 @@ public void testRestrictIsNoCPPKeyword_228826() throws Exception { // void test1(); // void test2() throw (); // void test3() throw (int); + @Test public void testEmptyExceptionSpecification_86943() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(getAboveComment(), CPP); @@ -6469,6 +6766,7 @@ public void testEmptyExceptionSpecification_86943() throws Exception { // } catch (const char &ex) { // } // } + @Test public void testScopeOfCatchHandler_209579() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6480,6 +6778,7 @@ public void testScopeOfCatchHandler_209579() throws Exception { // func(x); // func(y); // } + @Test public void testOverloadedFunction_248774() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction func1 = helper.assertNonProblem("func(x)", 4, ICPPFunction.class); @@ -6499,6 +6798,7 @@ public void testOverloadedFunction_248774() throws Exception { // func(x[0]); // func(y[0]); // } + @Test public void testOverloadedOperator_248803() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction func1 = helper.assertNonProblem("func(x[0])", 4, ICPPFunction.class); @@ -6524,6 +6824,7 @@ public void testOverloadedOperator_248803() throws Exception { // class C5 : C1 { // void m();//5 // }; + @Test public void testOverridden_248846() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class); @@ -6586,6 +6887,7 @@ public void testOverridden_248846() throws Exception { // void test(A* p) { // p.a; // should not resolve // } + @Test public void testPointerMemberAccess_245068() throws Exception { final String comment = getAboveComment(); final boolean[] isCpps = { false, true }; @@ -6599,6 +6901,7 @@ public void testPointerMemberAccess_245068() throws Exception { // template class CT {}; // } // using ns::CT; + @Test public void testTemplateIdInUsingDecl_251199() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6610,6 +6913,7 @@ public void testTemplateIdInUsingDecl_251199() throws Exception { // struct B { // operator ns::A(); // problems on operator ns and on A // }; + @Test public void testNamespaceQualifiedOperator_256840() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -6622,6 +6926,7 @@ public void testNamespaceQualifiedOperator_256840() throws Exception { // void test(int p) { // f(p); // } + @Test public void testFunctionExtraArgument() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("f(p)", 1); @@ -6632,6 +6937,7 @@ public void testFunctionExtraArgument() throws Exception { // void test(int* p) { // f(p); // } + @Test public void testVariadicFunction_2500582() throws Exception { final String comment = getAboveComment(); final boolean[] isCpps = { false, true }; @@ -6650,6 +6956,7 @@ public void testVariadicFunction_2500582() throws Exception { // // Should resolve to f(Incomplete*) since 0 can be converted to Incomplete* // f(0); // } + @Test public void testVariadicFunction_2500583() throws Exception { final String comment = getAboveComment(); final boolean[] isCpps = { false, true }; @@ -6672,6 +6979,7 @@ public void testVariadicFunction_2500583() throws Exception { // c(i,i)= 0; // c(i) = 0; // } + @Test public void testFunctionCallOnLHS_252695() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP, ScannerKind.GNU); @@ -6688,6 +6996,7 @@ public void testFunctionCallOnLHS_252695() throws Exception { // class B; // template class B; // template class B {}; + @Test public void testInvalidClassRedeclaration_254961() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); @@ -6706,6 +7015,7 @@ public void testInvalidClassRedeclaration_254961() throws Exception { // template class T> class B {}; // template class B; // template class B {}; + @Test public void testInvalidClassRedeclaration_364226() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); @@ -6723,6 +7033,7 @@ public void testInvalidClassRedeclaration_364226() throws Exception { // }; // void Foo::foo(void) { // } + @Test public void testVoidParamInDefinition_257376() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6740,6 +7051,7 @@ public void testVoidParamInDefinition_257376() throws Exception { // ns::C* cptr= 0; // C c= C(cptr); // } + @Test public void testNoKoenigForConstructors() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6751,6 +7063,7 @@ public void testNoKoenigForConstructors() throws Exception { // void test() { // donothing(); // } + @Test public void testVoidViaTypedef_258694() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -6765,6 +7078,7 @@ public void testVoidViaTypedef_258694() throws Exception { // static int& x = y; // y is not defined // int y; // }; + @Test public void testScopeOfClassMember_259460() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("B b", 1, ICPPClassType.class); @@ -6784,6 +7098,7 @@ public void testScopeOfClassMember_259460() throws Exception { // RED, GREEN // }; // }; + @Test public void testScopeOfClassMember_259648() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("GREEN)", 5, IEnumerator.class); @@ -6802,6 +7117,7 @@ public void testScopeOfClassMember_259648() throws Exception { // func(*a); // func(*b); // } + @Test public void testSmartPointerReference_259680() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPFunction f1 = ba.assertNonProblem("func(*a)", 4, ICPPFunction.class); @@ -6819,6 +7135,7 @@ public void testSmartPointerReference_259680() throws Exception { // (c == c.a && (c // int func(int i) { return i; } + @Test public void testFriendFunction_438114() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPFunction f1 = bh.assertNonProblemOnFirstIdentifier("func(int i);"); @@ -7085,6 +7411,7 @@ public void testFriendFunction_438114() throws Exception { // ca.bar();/*7*/ // a.bar();/*8*/ // } + @Test public void testMemberFunctionDisambiguationByCVness_238409() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -7138,6 +7465,7 @@ public void testMemberFunctionDisambiguationByCVness_238409() throws Exception { // void blabla2() { // test2(e1); // } + @Test public void testOverloadResolution_262191() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -7152,6 +7480,7 @@ public void testOverloadResolution_262191() throws Exception { // void* h; // select (int (h) + 1); // } + @Test public void testSimpleTypeConstructorExpressions() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -7165,6 +7494,7 @@ public void testSimpleTypeConstructorExpressions() throws Exception { // void test() { // f(a()); // } + @Test public void testBug263152a() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("f(a())", 1); @@ -7181,6 +7511,7 @@ public void testBug263152a() throws Exception { // void test(B p) { // p.m(a()); // } + @Test public void testBug263152b() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("m(a())", 1, ICPPMethod.class); @@ -7210,6 +7541,7 @@ public void _testInstanceMemberInStaticMethod_263154() throws Exception { // for (;A* a = 0;) {a= 0;} // for (;B* b;) {b= 0;} // } + @Test public void testAmbiguityResolutionInCondition_263158() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7224,6 +7556,7 @@ public void testAmbiguityResolutionInCondition_263158() throws Exception { // void test(void* ptr) { // delete (type)(ptr); // } + @Test public void testAmbiguityResolutionInDeleteExpression_428922() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7245,6 +7578,7 @@ public void testAmbiguityResolutionInDeleteExpression_428922() throws Exception // f(r); // f(s); // } + @Test public void testPointerToNonPointerConversion_263159() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("f(p)", 1); @@ -7262,6 +7596,7 @@ public void testPointerToNonPointerConversion_263159() throws Exception { // fip(0); // fia(0); // } + @Test public void testNonPointerToPointerConversion_263707() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("fip(1)", 3); @@ -7278,6 +7613,7 @@ public void testNonPointerToPointerConversion_263707() throws Exception { // reset(new cl()); // reset(new cl[1]); // } + @Test public void testTypeOfNewExpression_264163() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -7292,6 +7628,7 @@ public void testTypeOfNewExpression_264163() throws Exception { // range ir(0); // onRange(ir); // } + @Test public void testConstructorTemplateInImplicitConversion_264314() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7312,6 +7649,7 @@ public void testConstructorTemplateInImplicitConversion_264314() throws Exceptio // template class CT {}; // CT ct1; // CT ct2; + @Test public void testConstTypedef_264474() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7359,6 +7697,7 @@ public void testConstTypedef_264474() throws Exception { // mpr(&X::cm); // cm is const // mprc(&X::m); // m is not const // } + @Test public void testMemberPtrs_264479() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7384,6 +7723,7 @@ public void testMemberPtrs_264479() throws Exception { // void test(int* p) { // f(!p); // } + @Test public void testTypeOfNotExpression_265779() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("f(!p)", 1); @@ -7408,6 +7748,7 @@ public void testTypeOfNotExpression_265779() throws Exception { // void test(B& p) { // p.waldo(); // } + @Test public void testDependentEnumeration_446711a() throws Exception { parseAndCheckBindings(); } @@ -7434,6 +7775,7 @@ public void testDependentEnumeration_446711a() throws Exception { // void test(B& p) { // p.waldo(); // } + @Test public void testDependentEnumeration_446711b() throws Exception { parseAndCheckBindings(); } @@ -7460,6 +7802,7 @@ public void testDependentEnumeration_446711b() throws Exception { // void test(B& p) { // p.waldo(); // } + @Test public void testDependentEnumeration_446711c() throws Exception { parseAndCheckBindings(); } @@ -7486,6 +7829,7 @@ public void testDependentEnumeration_446711c() throws Exception { // void test(B& p) { // p.waldo(); // } + @Test public void testDependentEnumeration_446711d() throws Exception { parseAndCheckBindings(); } @@ -7512,6 +7856,7 @@ public void testDependentEnumeration_446711d() throws Exception { // void test(B& p) { // p.waldo(); // } + @Test public void testDependentEnumeration_446711e() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertProblemOnFirstIdentifier(".waldo()"); @@ -7528,6 +7873,7 @@ public void testDependentEnumeration_446711e() throws Exception { // temp = new ::S*; // temp = new (::S*); // } + @Test public void testNewPointerOfClass_267168() throws Exception { parseAndCheckBindings(); } @@ -7536,6 +7882,7 @@ public void testNewPointerOfClass_267168() throws Exception { // void f2(const char *(n[])) { // if (n && 1){} // } + @Test public void testPointerToArrayWithDefaultVal_267184() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7555,6 +7902,7 @@ public void testPointerToArrayWithDefaultVal_267184() throws Exception { // virtual void pv() = 0; // void (*ptrToFunc) ()= 0; // }; + @Test public void testPureVirtualVsInitDeclarator_267184() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP); @@ -7587,6 +7935,7 @@ public void testPureVirtualVsInitDeclarator_267184() throws Exception { // a.operator S *(); // } // } + @Test public void testLookupScopeForConversionNames_267221() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -7600,6 +7949,7 @@ public void testLookupScopeForConversionNames_267221() throws Exception { // int func() { // bar((A){foo()}); // } + @Test public void testBug268714() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -7611,6 +7961,7 @@ public void testBug268714() throws Exception { // int ** x; // f(x); // } + @Test public void testRankingOfQualificationConversion_269321() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -7632,6 +7983,7 @@ public void testRankingOfQualificationConversion_269321() throws Exception { // (1 + x).a; //2 // (x + 1.0).b; //3 // } + @Test public void testOverloadResolutionForOperators_266211() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("a; //1", 1, ICPPField.class); @@ -7652,6 +8004,7 @@ public void testOverloadResolutionForOperators_266211() throws Exception { // (x + x).a; //1 // (x + 1.0).a; //2 // } + @Test public void testOverloadResolutionForOperators_268534() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("a; //1", 1, ICPPField.class); @@ -7666,6 +8019,7 @@ public void testOverloadResolutionForOperators_268534() throws Exception { // C* c= 0; // test(c); // } + @Test public void testInvalidUserDefinedConversion_269729() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("test(c)", 4); @@ -7682,6 +8036,7 @@ public void testInvalidUserDefinedConversion_269729() throws Exception { // foo('a'); // foo(L'a'); // } + @Test public void testWideCharacterLiteralTypes_270892() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -7697,6 +8052,7 @@ public void testWideCharacterLiteralTypes_270892() throws Exception { // auto u8 = u8""; // auto u = u""; // auto U = U""; + @Test public void testStringLiteralPrefixTypes_526724() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -7730,6 +8086,7 @@ protected IType createStringType(Kind kind) { // using ns::A; // struct A; // A a; + @Test public void testForwardDeclarationAfterUsing_271236() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertNonProblem("A a;", 1, ICPPClassType.class); @@ -7737,6 +8094,7 @@ public void testForwardDeclarationAfterUsing_271236() throws Exception { // template class Moo; // bool getFile(Moo & res); + @Test public void testScopeOfClassFwdDecl_270831() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPClassType t = ba.assertNonProblem("Foo", 3, ICPPClassType.class); @@ -7758,6 +8116,7 @@ public void testScopeOfClassFwdDecl_270831() throws Exception { // test(d1); // test(C c) has to be selected // test(d2); // test(C c) has to be selected // } + @Test public void testDerivedToBaseConversion_269318() throws Exception { final String code = getAboveComment(); BindingAssertionHelper ba = new AST2AssertionHelper(code, true); @@ -7781,6 +8140,7 @@ public void testDerivedToBaseConversion_269318() throws Exception { // } a; // // int i = bar(a(1)); + @Test public void testCallToObjectOfClassType_267389() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -7791,6 +8151,7 @@ public void testCallToObjectOfClassType_267389() throws Exception { // C(T); // ctor // C(s); // instance s; // }; + @Test public void testDeclarationAmbiguity_269953() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP); @@ -7812,6 +8173,7 @@ public void testDeclarationAmbiguity_269953() throws Exception { // typedef C3 T3; // T3::C3(int) { // } + @Test public void testCtorWithTypedef_269953() throws Exception { parseAndCheckBindings(); } @@ -7823,6 +8185,7 @@ public void testCtorWithTypedef_269953() throws Exception { // }; // typedef Compare MY_COMPARE; // template<> MY_COMPARE::Compare() {} + @Test public void testTemplateCTorWithTypedef_269953() throws Exception { parseAndCheckBindings(); } @@ -7852,6 +8215,7 @@ public void testTemplateCTorWithTypedef_269953() throws Exception { // d.base(); // Parser log reports ambiguity on 'base' // return 0; // } + @Test public void testHiddenVirtualBase_282993() throws Exception { parseAndCheckBindings(); } @@ -7863,6 +8227,7 @@ public void testHiddenVirtualBase_282993() throws Exception { // C c; // c()()()()()()()()()()()()()(); // } + @Test public void testNestedOverloadedFunctionCalls_283324() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP); @@ -7873,7 +8238,7 @@ public void testNestedOverloadedFunctionCalls_283324() throws Exception { assertInstance(t, ICPPClassType.class); assertTrue(stmt.getExpression().isLValue()); final long time = System.currentTimeMillis() - now; - assertTrue("Lasted " + time + "ms", time < 5000); + assertTrue(time < 5000, "Lasted " + time + "ms"); } // class A { @@ -7883,6 +8248,7 @@ public void testNestedOverloadedFunctionCalls_283324() throws Exception { // void test(A a) { // m(a); // } + @Test public void testInlineFriendFunction_284690() throws Exception { parseAndCheckBindings(); } @@ -7900,6 +8266,7 @@ public void testInlineFriendFunction_284690() throws Exception { // f(u1); // f(l1); // } + @Test public void testEnumToIntConversion_285368() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPFunction f1 = ba.assertNonProblem("f(i1)", 1, ICPPFunction.class); @@ -7931,6 +8298,7 @@ public void testEnumToIntConversion_285368() throws Exception { // void test() { // f(i3); // } + @Test public void testCastInEnumeratorValue_446380() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); IEnumerator i2 = ba.assertNonProblem("i2", IEnumerator.class); @@ -7949,6 +8317,7 @@ public void testCastInEnumeratorValue_446380() throws Exception { } // typedef enum enum_name enum_name; + @Test public void testTypedefRecursion_285457() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ba.assertProblem("enum_name", 9); @@ -7958,6 +8327,7 @@ public void testTypedefRecursion_285457() throws Exception { // enum MyEnum {}; // MyStruct(MyEnum value) {} // }; + @Test public void testEnumRedefinitionInStruct_385144() throws Exception { parseAndCheckBindings(); } @@ -7968,6 +8338,7 @@ public void testEnumRedefinitionInStruct_385144() throws Exception { // x a; // } // }; + @Test public void testLookupFromInlineFriend_284690() throws Exception { parseAndCheckBindings(); } @@ -7985,6 +8356,7 @@ public void testLookupFromInlineFriend_284690() throws Exception { // void PropertyValueList::hello() { // XInterface temp; // } + @Test public void testTypeLookupWithMultipleInheritance_286213() throws Exception { parseAndCheckBindings(); } @@ -8002,6 +8374,7 @@ public void testTypeLookupWithMultipleInheritance_286213() throws Exception { // return ContainerOf::numParts; // } // }; + @Test public void testInheritanceFromMultipleInstancesOfSameTemplate_383502() throws Exception { parseAndCheckBindings(); } @@ -8017,6 +8390,7 @@ public void testInheritanceFromMultipleInstancesOfSameTemplate_383502() throws E // static const int v8= 1; // }; // const int X::v7= 1; + @Test public void testVariableDefVsDecl_286259() throws Exception { String[] declNames = { "v3" }; String[] defNames = { "v1", "v2", "v4", "v5", "X::v7" }; @@ -8034,6 +8408,7 @@ public void testVariableDefVsDecl_286259() throws Exception { // static const int v2= 1; // }; // const int X::v2; + @Test public void testVariableDefVsDecl_292635() throws Exception { String[] declNames = { "v1" }; String[] defNames = { "X::v2" }; @@ -8051,6 +8426,7 @@ public void testVariableDefVsDecl_292635() throws Exception { // struct T; // struct T* m2; // }; + @Test public void testStructOwner_290693() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8076,6 +8452,7 @@ public void testStructOwner_290693() throws Exception { // int main() { // return ~0; // } + @Test public void testNonUserdefinedOperator_291409b() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP); @@ -8093,6 +8470,7 @@ public void testNonUserdefinedOperator_291409b() throws Exception { // inline void Test::t() { // t<1>(); // } + @Test public void testMethodTemplateWithSameName_292051() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8117,6 +8495,7 @@ public void testMethodTemplateWithSameName_292051() throws Exception { // C c= *new C(); // foo(c); // } + @Test public void testUserDefinedConversion_222444a() throws Exception { parseAndCheckBindings(); } @@ -8144,6 +8523,7 @@ public void testUserDefinedConversion_222444a() throws Exception { // x2(f); // x3(f); // } + @Test public void testUserDefinedConversion_222444b() throws Exception { parseAndCheckBindings(); } @@ -8164,6 +8544,7 @@ public void testUserDefinedConversion_222444b() throws Exception { // foo(c); // foo(cc); // } + @Test public void testUserDefinedConversion_222444c() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8180,6 +8561,7 @@ public void testUserDefinedConversion_222444c() throws Exception { // int main() { // return B == 23; // } + @Test public void testInvalidOverload_291409() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code, CPP); @@ -8196,6 +8578,7 @@ public void testInvalidOverload_291409() throws Exception { // int* ptr; // f(ptr); // } + @Test public void testParameterAdjustment_293538() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8213,6 +8596,7 @@ public void testParameterAdjustment_293538() throws Exception { // // ns::A::A() : CT(1) { // } + @Test public void testLookupInConstructorChainInitializer_293566() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8231,6 +8615,7 @@ public void testLookupInConstructorChainInitializer_293566() throws Exception { // f(ns::e1 | ns::e2); // the operator| needs to be looked up in the // // associated namespace. // } + @Test public void testAssociatedScopesForOverloadedOperators_293589() throws Exception { parseAndCheckBindings(); } @@ -8242,6 +8627,7 @@ public void testAssociatedScopesForOverloadedOperators_293589() throws Exception // friend F friendFunction; // template F methodTemplate; // }; + @Test public void testFunctionDeclViaTypedef_86495() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8278,6 +8664,7 @@ public void testFunctionDeclViaTypedef_86495() throws Exception { // xx(&a); // f(""); // } + @Test public void testCVQualifiersWithArrays_293982() throws Exception { parseAndCheckBindings(); } @@ -8292,6 +8679,7 @@ public void testCVQualifiersWithArrays_293982() throws Exception { // f(a); func(a); // f(b); func(b); // } + @Test public void testArrayTypeSizeFromInitializer_294144() throws Exception { parseAndCheckBindings(); } @@ -8302,6 +8690,7 @@ public void testArrayTypeSizeFromInitializer_294144() throws Exception { // } // template struct C {}; // }; + @Test public void testLookupInClassScopeForTemplateIDs_294904() throws Exception { parseAndCheckBindings(); } @@ -8315,6 +8704,7 @@ public void testLookupInClassScopeForTemplateIDs_294904() throws Exception { // void test() { // func(A::array); // } + @Test public void testCompleteArrayTypeWithIncompleteDeclaration_294144() throws Exception { parseAndCheckBindings(); } @@ -8323,6 +8713,7 @@ public void testCompleteArrayTypeWithIncompleteDeclaration_294144() throws Excep // int x,y; // return y < x ? -1 : y > x ? 1 : 0; // } + @Test public void testSyntax1_295064() throws Exception { parseAndCheckBindings(); } @@ -8332,6 +8723,7 @@ public void testSyntax1_295064() throws Exception { // CT(TInt); // }; // template inline CT::CT(TInt) {} + @Test public void testSyntax2_295064() throws Exception { parseAndCheckBindings(); } @@ -8349,6 +8741,7 @@ public void testSyntax2_295064() throws Exception { // }; // static_assert(sizeof(VMPage) == 1, "bla"); // } + @Test public void testStaticAssertions_294730() throws Exception { parseAndCheckBindings(); } @@ -8387,6 +8780,7 @@ public void testStaticAssertions_294730() throws Exception { // foo(source_const_ref()); // #1 // foo(source_const_rvalue_ref()); // #1 // } + @Test public void testRValueReference_294730() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8427,6 +8821,7 @@ public void testRValueReference_294730() throws Exception { // const LRI&& r3 = i; // r3 has the type int& // RRI& r4 = i; // r4 has the type int& // RRI&& r5 = i; // r5 has the type int&& + @Test public void testRValueReferenceTypedefs_294730() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8474,6 +8869,7 @@ public void testRValueReferenceTypedefs_294730() throws Exception { // drref(2); // rcd3 refers to temporary with value 2.0 // cdref(cvd); // error: type qualifiers dropped // } + @Test public void testDirectBinding_294730() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8499,6 +8895,7 @@ public void testDirectBinding_294730() throws Exception { // void test(int) { // test(s()); // } + @Test public void testSpecialRuleForImplicitObjectType_294730() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8555,6 +8952,7 @@ public void testSpecialRuleForImplicitObjectType_294730() throws Exception { // sink3(z7); // } + @Test public void testInitOfClassObjectsByRValues_294730() throws Exception { final CharSequence[] contents = getContents(3); final String code = contents[0].toString(); @@ -8581,6 +8979,7 @@ public void testInitOfClassObjectsByRValues_294730() throws Exception { // check(c+1); // check(c+a); // } + @Test public void testADLForOperators_296906() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8597,6 +8996,7 @@ public void testADLForOperators_296906() throws Exception { // f(a, '1'); // calls ns::f(ns::A, char) // f(a, 1); // calls ns::f(ns::A, char) // } + @Test public void testADL_299101() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8624,6 +9024,7 @@ public void testADL_299101() throws Exception { // __typeof(a->x) t7(); // type is const double // __typeof((a->x)) t8(); // type is const double + @Test public void testDecltype_294730() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code, CPP); @@ -8657,12 +9058,14 @@ public void testDecltype_294730() throws Exception { // decltype(w)::type i; // int x = decltype(w)::value; // } + @Test public void testDecltypeInNameQualifier_380751() throws Exception { parseAndCheckBindings(); } // struct Base {}; // struct Derived : decltype(Base()) {}; + @Test public void testDecltypeInBaseSpecifier_438348() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPClassType base = helper.assertNonProblem("struct Base", "Base"); @@ -8683,6 +9086,7 @@ public void testDecltypeInBaseSpecifier_438348() throws Exception { // decltype(bar()(S())) v; // v.waldo(); // } + @Test public void testDecltypeWithConstantLambda_397494() throws Exception { parseAndCheckBindings(); } @@ -8695,12 +9099,14 @@ public void testDecltypeWithConstantLambda_397494() throws Exception { // f([this] (int x) {}); // } // }; + @Test public void testLambdaWithCapture() throws Exception { parseAndCheckBindings(); } // int foo = 0; // auto bar = [foo] { return foo; }; + @Test public void testLambdaWithCapture_446225() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPVariable foo1 = bh.assertNonProblemOnFirstIdentifier("foo =", ICPPVariable.class); @@ -8728,6 +9134,7 @@ public void testLambdaWithCapture_446225() throws Exception { // int p; // waldo({[p](int arg) { return true; }}); // } + @Test public void testLambdaWithCaptureInInitializerList_488265() throws Exception { parseAndCheckBindings(); } @@ -8759,6 +9166,7 @@ public void testLambdaWithCaptureInInitializerList_488265() throws Exception { // }; // // S::S(int a) : f{a} {} // Member initializer + @Test public void testInitSyntax_302412() throws Exception { parseAndCheckBindings(); } @@ -8797,6 +9205,7 @@ public void testInitSyntax_302412() throws Exception { // fs({1.0,2.0,3.0}); // fs({}); // } + @Test public void testListInitialization_302412a() throws Exception { parseAndCheckBindings(); } @@ -8820,6 +9229,7 @@ public void testListInitialization_302412a() throws Exception { // A a{ 1.0,2.0 }; // OK, uses #1 // g({ "foo", "bar" }); // OK, uses #3 // } + @Test public void testListInitialization_302412b() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8870,6 +9280,7 @@ public void testListInitialization_302412b() throws Exception { // X x1; // x({x1}); // OK, lvalue reference to x1 // } + @Test public void testListInitialization_302412c() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8894,6 +9305,7 @@ public void testListInitialization_302412c() throws Exception { // f({'a', 'b'}); // OK: f(A(int,double)) user-defined conversion // f({1.0}); // narrowing not detected by cdt. // } + @Test public void testListInitialization_302412d() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8914,6 +9326,7 @@ public void testListInitialization_302412d() throws Exception { // h({1.0}); // error: narrowing // h({ }); // OK: identity conversion // } + @Test public void testListInitialization_302412e() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -8950,6 +9363,7 @@ public void testListInitialization_302412e() throws Exception { // fH(1); // no conversion from int to H // fH({1}); // H(G(1)) // } + @Test public void testListInitialization_302412f() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertProblem("f({1,1})", 1); @@ -8978,6 +9392,7 @@ public void testListInitialization_302412f() throws Exception { // waldo({short(1)}); // waldo({1, 2}); // } + @Test public void testListInitialization_439477a() throws Exception { parseAndCheckBindings(); } @@ -8989,6 +9404,7 @@ public void testListInitialization_439477a() throws Exception { // waldo({1, 2, 3}); // should resolve to waldo(int const (&)[3]) // waldo({1, 2, 3, 4}); // should not resolve // } + @Test public void testListInitialization_439477b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -9024,6 +9440,7 @@ public void testListInitialization_439477b() throws Exception { // }; // // A waldo({{0}, {0}}); + @Test public void testListInitialization_458679() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -9040,6 +9457,7 @@ public void testListInitialization_458679() throws Exception { // void test() { // waldo({""}); // } + @Test public void testListInitialization_491842() throws Exception { parseAndCheckBindings(); } @@ -9055,6 +9473,7 @@ public void testListInitialization_491842() throws Exception { // A{1}; // A{1, 2}; // } + @Test public void testListInitializer_495227() throws Exception { parseAndCheckBindings(); BindingAssertionHelper ah = getAssertionHelper(); @@ -9089,6 +9508,7 @@ public void testListInitializer_495227() throws Exception { // int main() { // foo({3, 4.0, 'c'}); // 'foo' is ambiguous // } + @Test public void testAggregateInitialization_487555() throws Exception { parseAndCheckBindings(); } @@ -9111,6 +9531,7 @@ public void testAggregateInitialization_487555() throws Exception { // g1({a}); // g2({s}); // } + @Test public void testListInitializationOfClass() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -9129,6 +9550,7 @@ public void testListInitializationOfClass() throws Exception { // const str b = {"test", 4}; // ERROR, #2 fails, #1 is skipped explicit conversion // return str{p, i}; // OK, uses #1 to initialize, explicit constructor is considered too // } + @Test public void testListInitializationWithExplicitConstructor() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(true); @@ -9159,6 +9581,7 @@ public void testListInitializationWithExplicitConstructor() throws Exception { // const str b = {"test", 4}; // OK, #2 fails, uses #1 to initialize // return str{p, i}; // OK, uses #1 to initialize // } + @Test public void testListInitializationOfClassTypeId() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -9177,6 +9600,7 @@ public void testListInitializationOfClassTypeId() throws Exception { // auto t = new auto({1.0}); // auto x; // Error - missing initializer. // auto y = { 1.0, 5 }; // Error - inconsistent types in the array initializer. + @Test public void testAutoType_289542() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9210,6 +9634,7 @@ public void testAutoType_289542() throws Exception { // void test() { // for (auto a : a) {} // } + @Test public void testAutoType_305970() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPVariable x = bh.assertNonProblem("x =", 1, ICPPVariable.class); @@ -9222,6 +9647,7 @@ public void testAutoType_305970() throws Exception { // struct A { auto a = 1; }; // Auto-typed non-static fields are not allowed. // struct B { static auto b = 1; }; // Auto-typed static fields are ok. + @Test public void testAutoType_305987() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9233,6 +9659,7 @@ public void testAutoType_305987() throws Exception { // auto fpif1(int)->int(*)(int) // auto fpif2(int)->int(*)(int) {} + @Test public void testNewFunctionDeclaratorSyntax_305972() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9250,6 +9677,7 @@ public void testNewFunctionDeclaratorSyntax_305972() throws Exception { // enum EUnscoped1 {b1}; // enum EUnscoped2 : long {b2}; // enum EUnscoped3 : int; + @Test public void testScopedEnums_305975a() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9305,6 +9733,7 @@ public void testScopedEnums_305975a() throws Exception { // enum F y1 = a; // OK // enum E1 : int; // OK: E1 is un-scoped, underlying type is int // enum class F1; // OK: F1 is scoped, underlying type is int + @Test public void testScopedEnums_305975b() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9313,6 +9742,7 @@ public void testScopedEnums_305975b() throws Exception { // enum class E x2 = E::a; // illegal (elaborated type specifier) // enum class F y2 = a; // illegal // enum E; // illegal + @Test public void testScopedEnums_305975c() throws Exception { String code = getAboveComment(); IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); @@ -9333,6 +9763,7 @@ public void testScopedEnums_305975c() throws Exception { // fint(Col::red); // error: no conversion to int // fbool(Col::red); // error: no Col to bool conversion // } + @Test public void testScopedEnums_305975d() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9364,6 +9795,7 @@ public void testScopedEnums_305975d() throws Exception { // i = p->f(X::xr); // OK // i = p->f(p->xl); // OK // } + @Test public void testScopedEnums_305975e() throws Exception { parseAndCheckBindings(); } @@ -9378,6 +9810,7 @@ public void testScopedEnums_305975e() throws Exception { // xdir d; // error: xdir not in scope // xl; // error: not in scope // } + @Test public void testScopedEnums_305975f() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9392,6 +9825,7 @@ public void testScopedEnums_305975f() throws Exception { // enum class Y {e1, e2= f(e1)+2, e3}; // enum A {e1, e2= e1+2, e3}; // enum B {e1, e2= f(e1)+2, e3}; + @Test public void testScopedEnums_305975g() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9405,6 +9839,7 @@ public void testScopedEnums_305975g() throws Exception { // enum S::waldo1 : int { // someConstant = 1508 // }; + @Test public void testForwardDeclaringEnumAtClassScope_475894() throws Exception { parseAndCheckBindings(); } @@ -9417,6 +9852,7 @@ public void testForwardDeclaringEnumAtClassScope_475894() throws Exception { // f(sizeof(S::m)); // // f(sizeof(S::m + 1)); // Error not detected by CDT: reference to non-static member in subexpression // } + @Test public void testSizeofOfNonstaticMember_305979() throws Exception { parseAndCheckBindings(); } @@ -9431,11 +9867,13 @@ public void testSizeofOfNonstaticMember_305979() throws Exception { // B b; // b.waldo(); // } + @Test public void testSizeofReference_397342() throws Exception { parseAndCheckBindings(); } // constexpr int waldo = sizeof("cat\b\\\n"); + @Test public void testSizeofStringLiteralWithEscapeCharacters_459279() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPVariable waldo = helper.assertNonProblem("waldo"); @@ -9449,6 +9887,7 @@ public void testSizeofStringLiteralWithEscapeCharacters_459279() throws Exceptio // A& b; // }; // A* p; + @Test public void testSizeofStructWithReferenceField_397342() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IASTName nameB = bh.findName("B"); @@ -9461,6 +9900,7 @@ public void testSizeofStructWithReferenceField_397342() throws Exception { } // struct waldo {}; + @Test public void testSizeofEmptyStruct_457770() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IASTName nameWaldo = bh.findName("waldo"); @@ -9479,6 +9919,7 @@ public void testSizeofEmptyStruct_457770() throws Exception { // B b; // b.waldo(); // } + @Test public void testAlignof_451082() throws Exception { parseAndCheckBindings(); } @@ -9491,6 +9932,7 @@ public void testAlignof_451082() throws Exception { // f(c16); // f(c32); // } + @Test public void testNewCharacterTypes_305976() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9506,6 +9948,7 @@ public void testNewCharacterTypes_305976() throws Exception { // void (11); // return 42; // } + @Test public void testCastToVoid_309155() throws Exception { parseAndCheckBindings(); } @@ -9513,6 +9956,7 @@ public void testCastToVoid_309155() throws Exception { // void test() { // void *libHandle (0); // } + @Test public void testCtorInitializerForVoidPtr_314113() throws Exception { parseAndCheckBindings(); } @@ -9529,6 +9973,7 @@ public void testCtorInitializerForVoidPtr_314113() throws Exception { // C c; // f(c+1); // converts c to a char and calls operator+(int, int) // } + @Test public void testBuiltinOperators_294543a() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9547,6 +9992,7 @@ public void testBuiltinOperators_294543a() throws Exception { // A a; // f(a= 1); // A cannot be converted to long& here // } + @Test public void testBuiltinOperators_294543b() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9564,6 +10010,7 @@ public void testBuiltinOperators_294543b() throws Exception { // int i; // f(i = a); // A converts to long&, builtin assignment to i used, f(long) called // } + @Test public void testBuiltinOperators_294543c() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), true); @@ -9596,6 +10043,7 @@ public void testBuiltinOperators_294543c() throws Exception { // f(a = 2); // OK, uses const assignment overload, calls f(A) // g(a = 3); // OK, uses const assignment overload, converts to int, calls g(long) // } + @Test public void testBuiltinOperators_294543d() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), true); @@ -9638,6 +10086,7 @@ public void testBuiltinOperators_294543d() throws Exception { // Y* m();//2 // Y* m(Y*);//3 // }; + @Test public void testOverrideSimpleCovariance_321617() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPMethod m0 = helper.assertNonProblem("m();//0", 1, ICPPMethod.class); @@ -9690,6 +10139,7 @@ public void testOverrideSimpleCovariance_321617() throws Exception { // c.f(); // c.C::f(); // } + @Test public void testResolutionToFinalOverrider_86654() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -9708,6 +10158,7 @@ public void testResolutionToFinalOverrider_86654() throws Exception { // X::X() = default; // int f(int) = delete; // auto g() -> int = delete; + @Test public void testDefaultedAndDeletedFunctions_305978() throws Exception { String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code); @@ -9737,6 +10188,7 @@ public void testDefaultedAndDeletedFunctions_305978() throws Exception { // const int b=12; // void f(int a= b) = delete ; + @Test public void testDefaultedAndDeletedFunctions_305978b() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9778,6 +10230,7 @@ public void testDefaultedAndDeletedFunctions_305978b() throws Exception { // g(a); // gb(a); // } + @Test public void testInlineNamespace_305980a() throws Exception { parseAndCheckBindings(); } @@ -9791,6 +10244,7 @@ public void testInlineNamespace_305980a() throws Exception { // ns::m::a; // ns::a; // } + @Test public void testInlineNamespace_305980b() throws Exception { parseAndCheckBindings(); } @@ -9812,6 +10266,7 @@ public void testInlineNamespace_305980b() throws Exception { // ::f(1); // ::g(1); // } + @Test public void testInlineNamespace_305980c() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9833,6 +10288,7 @@ public void testInlineNamespace_305980c() throws Exception { // } // } // void ns::f() {} + @Test public void testInlineNamespace_305980d() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9864,6 +10320,7 @@ public void testInlineNamespace_305980d() throws Exception { // [](int p) -> char {}; // } // }; + @Test public void testLambdaExpression_316307a() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -9877,6 +10334,7 @@ public void testLambdaExpression_316307a() throws Exception { // return abs(a) < abs(b); // }); // } + @Test public void testLambdaExpression_316307b() throws Exception { parseAndCheckBindings(); } @@ -9889,6 +10347,7 @@ public void testLambdaExpression_316307b() throws Exception { // void waldo(); // function f = [this](){ waldo(); }; // }; + @Test public void testLambdaInDefaultMemberInitializer_494182() throws Exception { parseAndCheckBindings(); } @@ -9897,6 +10356,7 @@ public void testLambdaInDefaultMemberInitializer_494182() throws Exception { // // void f(const MyType& val); // void g(MyType& val); + @Test public void testTypeString_323596() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9921,6 +10381,7 @@ public void testTypeString_323596() throws Exception { // } // container cnt; // }; + @Test public void testConstMember_323599() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9941,6 +10402,7 @@ public void testConstMember_323599() throws Exception { // fint(pe + pe); // problem // fint(p + p); // converted to boolean and then int. // }; + @Test public void testExplicitConversionOperators() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -9958,6 +10420,7 @@ public void testExplicitConversionOperators() throws Exception { // D d; // C c (d); // } + @Test public void testExplicitOperatorInDirectInit() throws Exception { String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code); @@ -9976,6 +10439,7 @@ public void testExplicitOperatorInDirectInit() throws Exception { // f("abc"); // g("abc"); // } + @Test public void testRankingOfDeprecatedConversionOnStringLiteral() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -10002,6 +10466,7 @@ public void testRankingOfDeprecatedConversionOnStringLiteral() throws Exception // a+a; // xvalue // ar; // rvalue // } + @Test public void testXValueCategories() throws Exception { String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code); @@ -10040,6 +10505,7 @@ public void testXValueCategories() throws Exception { // int k = g(f1()); // calls g(const int&&) // int l = g(f2()); // calls g(const int&&) // } + @Test public void testRankingOfReferenceBindings_a() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IFunction g1 = bh.assertNonProblemOnFirstIdentifier("g(const int&)"); @@ -10070,6 +10536,7 @@ public void testRankingOfReferenceBindings_a() throws Exception { // A().p();//5 // calls A::p()&& // a.p();//6 // calls A::p()& // } + @Test public void testRankingOfReferenceBindings_b() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPMethod s1 = bh.assertNonProblem("operator<<(int)", 10); @@ -10104,6 +10571,7 @@ public void testRankingOfReferenceBindings_b() throws Exception { // S s1 = { 1.0, 2.0, 3.0 }; // invoke #1 // S s2 = { 1, 2, 3 }; // invoke #2 // S s3 = { }; // invoke #3 + @Test public void testEmptyInitializerList_324096() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -10134,6 +10602,7 @@ public void testEmptyInitializerList_324096() throws Exception { // int main() { // waldo({1, 2}); // } + @Test public void testIntToBoolConversionInInitList_521543() throws Exception { parseAndCheckBindings(); } @@ -10148,6 +10617,7 @@ public void testIntToBoolConversionInInitList_521543() throws Exception { // int i; // } // int j = A::i; + @Test public void testInlineNamespaceLookup_324096() throws Exception { parseAndCheckBindings(); } @@ -10161,6 +10631,7 @@ public void testInlineNamespaceLookup_324096() throws Exception { // C c; // f(true ? c : 1); // calls f(int), not f(C); // } + @Test public void testConditionalOperator_324853a() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IBinding f = bh.assertNonProblem("f(int);", 1); @@ -10176,6 +10647,7 @@ public void testConditionalOperator_324853a() throws Exception { // f(0 ? p : ""); // uses f(const char*); // g(0 ? p : ""); // converts "" to char* // } + @Test public void testConditionalOperator_324853b() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IBinding fc = bh.assertNonProblem("f(const char*);", 1); @@ -10197,6 +10669,7 @@ public void testConditionalOperator_324853b() throws Exception { // C c3 ({1,2}); // C(C(int, int)) // copy ctor is elided // C c4 ={1,2}; // C(C(int, int)) // copy ctor is elided // C c5 {1,2}; // C(int, int) + @Test public void testCtorForAutomaticVariables_156668() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -10229,6 +10702,7 @@ public void testCtorForAutomaticVariables_156668() throws Exception { // int number = 5; // g(&number); // } + @Test public void testTopLevelRestrictQualifier_327328() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -10249,6 +10723,7 @@ public void testTopLevelRestrictQualifier_327328() throws Exception { // f(&rnumber); // calls f(int* __restrict* a) // f(&number); // calls f(int** a) // } + @Test public void testOverloadingWithRestrictQualifier_327328() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -10266,6 +10741,7 @@ public void testOverloadingWithRestrictQualifier_327328() throws Exception { // }; // typedef const S T; // T::C c; + @Test public void testCVQualifiedClassName_328063() throws Exception { parseAndCheckBindings(); } @@ -10275,6 +10751,7 @@ public void testCVQualifiedClassName_328063() throws Exception { // for (int& x : array) // x *= 2; // } + @Test public void testRangeBasedForLoop_327223() throws Exception { parseAndCheckBindings(); } @@ -10293,6 +10770,7 @@ public void testRangeBasedForLoop_327223() throws Exception { // void test(D& c) { // func(c.get()); // error. // } + @Test public void testOverrideUsingDeclaredMethod_328802() throws Exception { parseAndCheckBindings(); } @@ -10308,6 +10786,7 @@ public void testOverrideUsingDeclaredMethod_328802() throws Exception { // int y; // }; // } + @Test public void testOwner() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPNamespace ns = bh.assertNonProblemOnFirstIdentifier("ns"); @@ -10326,11 +10805,13 @@ public void testOwner() throws Exception { // A(int a = f()); // static int f(); // }; + @Test public void testFwdLookupForDefaultArgument() throws Exception { parseAndCheckBindings(); } // auto f2 (); // missing late return type. + @Test public void testBug332114a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); IBinding b = bh.assertNonProblem("f2", 0); @@ -10341,6 +10822,7 @@ public void testBug332114a() throws Exception { // enum E: short; // enum E: short; // enum E: short {e1, e2}; + @Test public void testBug332114b() throws Exception { parseAndCheckBindings(); } @@ -10353,6 +10835,7 @@ public void testBug332114b() throws Exception { // for (auto& s : array) // s.f(); // ERROR HERE // } + @Test public void testAutoTypeInRangeBasedFor_332883a() throws Exception { parseAndCheckBindings(); } @@ -10370,6 +10853,7 @@ public void testAutoTypeInRangeBasedFor_332883a() throws Exception { // for (auto s : range) // s.f(); // ERROR HERE // } + @Test public void testAutoTypeInRangeBasedFor_332883b() throws Exception { parseAndCheckBindings(); } @@ -10397,6 +10881,7 @@ public void testAutoTypeInRangeBasedFor_332883b() throws Exception { // for (const auto& r : p) // r.x; // } + @Test public void testAutoTypeInRangeBasedFor_332883c() throws Exception { parseAndCheckBindings(); } @@ -10413,6 +10898,7 @@ public void testAutoTypeInRangeBasedFor_332883c() throws Exception { // e.f(); // } // } + @Test public void testAutoTypeInRangeBasedFor_359653() throws Exception { parseAndCheckBindings(); } @@ -10430,6 +10916,7 @@ public void testAutoTypeInRangeBasedFor_359653() throws Exception { // int main() { // for (auto x : C()); // ERROR: Symbol 'begin' could not be resolved // } + @Test public void testRangedBasedFor_538517() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -10439,6 +10926,7 @@ public void testRangedBasedFor_538517() throws Exception { // int a, b; // B(T) : a(0), b(0) {} // }; + @Test public void testMemberInitializer_333200() throws Exception { parseAndCheckBindings(); } @@ -10447,6 +10935,7 @@ public void testMemberInitializer_333200() throws Exception { // template auto add(T t, U u) -> decltype(t + u) { // return t + u; // } + @Test public void testResolutionInTrailingReturnType_333256() throws Exception { parseAndCheckBindings(); } @@ -10457,6 +10946,7 @@ public void testResolutionInTrailingReturnType_333256() throws Exception { // struct Derived : Base { // virtual auto waldo() -> bool override; // }; + @Test public void testOverrideSpecifierAfterTrailingReturnType_489876() throws Exception { parseAndCheckBindings(); } @@ -10469,6 +10959,7 @@ public void testOverrideSpecifierAfterTrailingReturnType_489876() throws Excepti // // auto (*z1)() -> auto(*)() -> int(*)(); // int (*(*(*z2)())())(); + @Test public void testTrailingReturnTypeInFunctionPointer() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -10492,6 +10983,7 @@ public void testTrailingReturnTypeInFunctionPointer() throws Exception { // CHAINER c; // test((c,0,1)); // } + @Test public void testOverloadedCommaOpWithConstClassRef_334955() throws Exception { parseAndCheckBindings(); } @@ -10509,6 +11001,7 @@ public void testOverloadedCommaOpWithConstClassRef_334955() throws Exception { // os ss; // (ss << "").ok; // } + @Test public void testOverloadedOperatorWithInheritanceDistance_335387() throws Exception { parseAndCheckBindings(); } @@ -10533,12 +11026,14 @@ public void testOverloadedOperatorWithInheritanceDistance_335387() throws Except // void waldo(Bitmap& icon) { // icon.IsOk(); // ERROR: "Method 'IsOk' could not be resolved" // } + @Test public void testBaseComputationWhileTypeIsIncomplete_498393() throws Exception { parseAndCheckBindings(); } // namespace ns {int a;} // using ns::a; + @Test public void testPropertyOfUsingDeclaration() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); ICPPASTUsingDeclaration udecl = getDeclaration(tu, 1); @@ -10556,6 +11051,7 @@ public void testPropertyOfUsingDeclaration() throws Exception { // S s[1]; // s->foo(); // } + @Test public void testMemberAccessForArray_347298() throws Exception { parseAndCheckBindings(); } @@ -10570,6 +11066,7 @@ public void testMemberAccessForArray_347298() throws Exception { // Y y2 = y; // X x = y2; // } + @Test public void testReferenceToCopyConstructor() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); ICPPASTFunctionDefinition fdef = getDeclaration(tu, 2); @@ -10605,6 +11102,7 @@ public void testReferenceToCopyConstructor() throws Exception { // void xx() { // MyCallback x= MyCallback(&Foo::Method); // Invalid overload of 'Foo::Method' // } + @Test public void testTypedefAsClassNameWithFunctionPtrArgument_350345() throws Exception { parseAndCheckBindings(); } @@ -10622,6 +11120,7 @@ public void testTypedefAsClassNameWithFunctionPtrArgument_350345() throws Except // void f2(int (x), int y=x) { // x= 1; // } + @Test public void testAmbiguityResolution_354599() throws Exception { parseAndCheckBindings(); } @@ -10643,6 +11142,7 @@ public void testAmbiguityResolution_354599() throws Exception { // C c; // c.method(b); // } + @Test public void testAmbiguityResolution_356268() throws Exception { parseAndCheckBindings(); } @@ -10650,6 +11150,7 @@ public void testAmbiguityResolution_356268() throws Exception { // void (g)(char); // void (g)(int); //1 // void (g)(int); //2 + @Test public void testFunctionRedeclarations() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IFunction g1 = bh.assertNonProblem("g)(char)", 1); @@ -10665,12 +11166,14 @@ public void testFunctionRedeclarations() throws Exception { // int r = 12; // return r; // } + @Test public void testVariableDeclarationInIfStatement() throws Exception { parseAndCheckBindings(); } // class A : A { // }; + @Test public void testRecursiveClassInheritance_357256() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPClassType c = bh.assertNonProblem("A", 1); @@ -10685,6 +11188,7 @@ public void testRecursiveClassInheritance_357256() throws Exception { // }; // template<> struct CT2 { // Accessed before ambiguity is resolved // }; + @Test public void testAmbiguityResolution_359364() throws Exception { parseAndCheckBindings(); } @@ -10705,6 +11209,7 @@ public void testAmbiguityResolution_359364() throws Exception { // template<> // struct B { // }; + @Test public void testAmbiguityResolution_427854() throws Exception { parseAndCheckBindings(); } @@ -10716,6 +11221,7 @@ public void testAmbiguityResolution_427854() throws Exception { // T(); // ~T(); // }; + @Test public void testErrorForDestructorWithWrongName_367590() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.STD, false); IASTCompositeTypeSpecifier S; @@ -10745,6 +11251,7 @@ public void testErrorForDestructorWithWrongName_367590() throws Exception { // f(i64); // f(word); // } + @Test public void testModeAttribute_330635() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); String[] calls = { "f(i8)", "f(i16)", "f(i32)", "f(i64)", "f(word)" }; @@ -10754,18 +11261,19 @@ public void testModeAttribute_330635() throws Exception { } for (int i = 0; i < functions.length - 1; i++) { for (int j = 0; j < i; j++) { - assertNotSame(calls[i] + " and " + calls[j] + " resolve to the same function", functions[i], - functions[j]); + assertNotSame(functions[i], functions[j], + calls[i] + " and " + calls[j] + " resolve to the same function"); } } - assertSame(calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions", - functions[calls.length - 1], functions[calls.length - 2]); + assertSame(functions[calls.length - 1], functions[calls.length - 2], + calls[calls.length - 1] + " and " + calls[calls.length - 2] + " resolve to different functions"); } // void f(int x) try { // } catch(...) { // (void)x; // } + @Test public void testParentScopeOfCatchHandler_376246() throws Exception { parseAndCheckBindings(); } @@ -10775,6 +11283,7 @@ public void testParentScopeOfCatchHandler_376246() throws Exception { // void doSomething() throw(MyException); // }; // void MyClass::doSomething() throw (MyException) {} + @Test public void testScopeOfExceptionSpecification_377457() throws Exception { parseAndCheckBindings(); } @@ -10814,6 +11323,7 @@ public void testScopeOfExceptionSpecification_377457() throws Exception { // h( nullptr ); // deduces T = nullptr_t // h( (float*) nullptr ); // deduces T = float* // } + @Test public void testNullptr_327298a() throws Exception { parseAndCheckBindings(); } @@ -10832,6 +11342,7 @@ public void testNullptr_327298a() throws Exception { // void testtemplates() { // g( nullptr ); // error // } + @Test public void testNullptr_327298b() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertProblem("checkNullPtr(1)", 12); @@ -10845,6 +11356,7 @@ public void testNullptr_327298b() throws Exception { // f( nullptr ); // calls f( char* ) // f( 0 ); // calls f( int ) // } + @Test public void testNullptr_327298c() throws Exception { parseAndCheckBindings(); BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); @@ -10855,6 +11367,7 @@ public void testNullptr_327298c() throws Exception { } // void foo(struct S s); + @Test public void testParameterForwardDeclaration_379511() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPClassType struct = bh.assertNonProblem("S", 1, ICPPClassType.class); @@ -10867,6 +11380,7 @@ public void testParameterForwardDeclaration_379511() throws Exception { // struct S { // friend F; // }; + @Test public void testFriendClass() throws Exception { parseAndCheckBindings(); } @@ -10876,6 +11390,7 @@ public void testFriendClass() throws Exception { // struct S { // friend T; // }; + @Test public void testFriendTypedef() throws Exception { parseAndCheckBindings(); } @@ -10884,6 +11399,7 @@ public void testFriendTypedef() throws Exception { // struct T { // friend P; // }; + @Test public void testFriendTemplateParameter() throws Exception { parseAndCheckBindings(); } @@ -10897,6 +11413,7 @@ public void testFriendTemplateParameter() throws Exception { // friend foo::foo(); // friend foo::~foo(); // }; + @Test public void testFriendConstructorDestructor_400940() throws Exception { parseAndCheckBindings(); } @@ -10911,6 +11428,7 @@ public void testFriendConstructorDestructor_400940() throws Exception { // void foo() { // Waldo c; // error here // } + @Test public void testFriendClassLookup_512932() throws Exception { parseAndCheckBindings(); } @@ -10919,6 +11437,7 @@ public void testFriendClassLookup_512932() throws Exception { // virtual void mFuncDecl() final; // virtual void mFuncDef() final {} // }; + @Test public void testFinalFunction() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -10949,6 +11468,7 @@ public void testFinalFunction() throws Exception { // void mFuncDecl() override; // void mFuncDef() override {} // }; + @Test public void testOverrideFunction() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -10979,6 +11499,7 @@ public void testOverrideFunction() throws Exception { // void mFuncDecl() final override; // void mFuncDef() final override {} // }; + @Test public void testOverrideFinalFunction() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11011,6 +11532,7 @@ private void assertVirtualSpecifiers(ICPPASTFunctionDeclarator declarator, boole // }; // struct S final : public Base { // }; + @Test public void testFinalClass() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11042,6 +11564,7 @@ public void testFinalClass() throws Exception { // S s; // s.foo(1); // } + @Test public void testFinalTemplateMethod() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11058,6 +11581,7 @@ public void testFinalTemplateMethod() throws Exception { // final = 4; // override = 2; // } + @Test public void testFinalAndOverrideVariables() throws Exception { parseAndCheckBindings(); } @@ -11068,12 +11592,14 @@ public void testFinalAndOverrideVariables() throws Exception { // void foo(struct S final) { // final.i = 23; // } + @Test public void testFinalParameter() throws Exception { parseAndCheckBindings(); } // struct S __final {}; // struct T { void foo() __final; }; + @Test public void testFinalGccExtension_442457() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPClassType s = bh.assertNonProblem("S"); @@ -11091,6 +11617,7 @@ public void testFinalGccExtension_442457() throws Exception { // struct U { // static const bool value = __is_trivially_constructible(S, Args...); // }; + @Test public void testParsingOfGcc5TypeTraitIntrinsics_485713() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } @@ -11103,6 +11630,7 @@ public void testParsingOfGcc5TypeTraitIntrinsics_485713() throws Exception { // bool operator==(S1 a, int r ); // static const int x = sizeof(CT((TD * (CT::*)) 0)); // template bool operator==(S1 a, const CT& r); + @Test public void testOrderInAmbiguityResolution_390759() throws Exception { parseAndCheckBindings(); } @@ -11118,6 +11646,7 @@ public void testOrderInAmbiguityResolution_390759() throws Exception { // int main() { // bar(N::A); // } + @Test public void testADLForFunctionObject_388287() throws Exception { parseAndCheckBindings(); } @@ -11145,6 +11674,7 @@ public void testADLForFunctionObject_388287() throws Exception { // foo(outer::waldo{}); // foo(outer::E{}); // } + @Test public void testADL_485710() throws Exception { parseAndCheckBindings(); } @@ -11157,6 +11687,7 @@ public void testADL_485710() throws Exception { // struct S {}; // const bool b = __is_base_of(S, int); // typedef A::type T; + @Test public void testIsBaseOf_395019() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11195,6 +11726,7 @@ public void testIsBaseOf_395019() throws Exception { // using Waldo = B; // // Waldo c; + @Test public void testIsBaseOf_446094() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11261,6 +11793,7 @@ public void testIsBaseOf_446094() throws Exception { // fint({vbool}); // fint({vchar}); // } + @Test public void testNarrowingConversionsInListInitialization_389782() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -11297,6 +11830,7 @@ public void testNarrowingConversionsInListInitialization_389782() throws Excepti // void test() { // waldo({1}); // } + @Test public void testNarrowingConversionInListInitialization_491748() throws Exception { parseAndCheckBindings(); } @@ -11334,6 +11868,7 @@ public void testNarrowingConversionInListInitialization_491748() throws Exceptio // std::string fine2(int i) { // return i ? "a" : "b"; // } + @Test public void testThrowExpressionInConditional_396663() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11347,6 +11882,7 @@ public void testThrowExpressionInConditional_396663() throws Exception { // int main() { // foo(true ? new A() : new B()); // } + @Test public void testBasePointerConverstionInConditional_462705() throws Exception { parseAndCheckBindings(); } @@ -11358,6 +11894,7 @@ public void testBasePointerConverstionInConditional_462705() throws Exception { // int main() { // waldo(false ? s : 0); // } + @Test public void testTypedefOfPointerInConditional_481078() throws Exception { parseAndCheckBindings(); } @@ -11372,6 +11909,7 @@ public void testTypedefOfPointerInConditional_481078() throws Exception { // struct base {}; // struct derived : base {}; // typedef enable_if<__is_base_of(base, derived)>::type T; + @Test public void testIsBaseOf_399353() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11380,6 +11918,7 @@ public void testIsBaseOf_399353() throws Exception { // struct derived : base {}; // typedef derived derived2; // const bool value = __is_base_of(base, derived2); + @Test public void testIsBaseOf_409100() throws Exception { BindingAssertionHelper b = getAssertionHelper(); IVariable var = b.assertNonProblem("value"); @@ -11391,6 +11930,7 @@ public void testIsBaseOf_409100() throws Exception { // class Inner {}; // }; // } + @Test public void testNestedClassScopeInlineDefinition_401661() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11409,6 +11949,7 @@ public void testNestedClassScopeInlineDefinition_401661() throws Exception { // }; // } // class NS::Enclosing::Inner{}; + @Test public void testNestedClassScopeSeparateDefinition_401661() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11424,6 +11965,7 @@ public void testNestedClassScopeSeparateDefinition_401661() throws Exception { // namespace NS { // class Inner {}; // } + @Test public void testClassScopeInlineDefinition_401661() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11440,6 +11982,7 @@ public void testClassScopeInlineDefinition_401661() throws Exception { // class Inner; // } // class NS::Inner{}; + @Test public void testClassScopeSeparateDefinition_401661() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -11468,6 +12011,7 @@ public void testClassScopeSeparateDefinition_401661() throws Exception { // void privateMemberFunction(); // class privateNestedClass {}; // }; + @Test public void testMemberAccessibilities() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -11508,6 +12052,7 @@ public void testMemberAccessibilities() throws Exception { // __sync_val_compare_and_swap(&i, 1, 2); // __sync_synchronize(); // } + @Test public void testGNUSyncBuiltins_389578() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11517,6 +12062,7 @@ public void testGNUSyncBuiltins_389578() throws Exception { // __sync_bool_compare_and_swap(&p, p, p); // __sync_fetch_and_add(&p, p, 2); // } + @Test public void testGNUSyncBuiltinsOnVoidPtr_533822() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11530,6 +12076,7 @@ public void testGNUSyncBuiltinsOnVoidPtr_533822() throws Exception { // int __int128_t; // int __uint128_t; // } + @Test public void testGCCIntBuiltins_444577() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11558,6 +12105,7 @@ public void testGCCIntBuiltins_444577() throws Exception { // typedef underlying_type::type int_type; // typedef underlying_type::type ulong_type; // typedef underlying_type::type loong_type; + @Test public void testUnderlyingTypeBuiltin_411196() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -11578,6 +12126,7 @@ public void testUnderlyingTypeBuiltin_411196() throws Exception { // }; // enum class E : short {}; // using target = underlying_type::type; + @Test public void testUnderlyingType_548954() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); assertSameType((ITypedef) helper.assertNonProblem("target"), CPPBasicType.SHORT); @@ -11596,6 +12145,7 @@ public void testUnderlyingType_548954() throws Exception { // void test() { // bar(2); // } + @Test public void testUnderlyingType_540909() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } @@ -11609,6 +12159,7 @@ public void testUnderlyingType_540909() throws Exception { // void foo() { // bar('a'); // Invalid arguments 'Candidates are: void bar(@120932903)' // } + @Test public void testUnderlyingType_568625() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } @@ -11621,6 +12172,7 @@ public void testUnderlyingType_568625() throws Exception { // intFunc(__builtin_expect(i, 0)); // ptrFunc(__builtin_return_address(4)); // } + @Test public void testGCCBuiltins_512932a() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -11634,6 +12186,7 @@ public void testGCCBuiltins_512932a() throws Exception { // intFunc(__builtin_expect(pI, (int*)0)); // ptrFunc(__builtin_expect(i, 0)); // } + @Test public void testGCCBuiltins_512932b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertProblem("__builtin_assume_aligned", "__builtin_assume_aligned"); @@ -11655,6 +12208,7 @@ public void testGCCBuiltins_512932b() throws Exception { // } // } // } + @Test public void testQualifiedNameLookup() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); @@ -11701,6 +12255,7 @@ public void testQualifiedNameLookup() throws Exception { // test(*a); // } // }; + @Test public void testBuiltInOperator_423396() throws Exception { parseAndCheckBindings(); } @@ -11714,6 +12269,7 @@ public void testBuiltInOperator_423396() throws Exception { // test(*a); // } // }; + @Test public void testBuiltInOperatorFunctionType_423396() throws Exception { parseAndCheckBindings(); } @@ -11723,6 +12279,7 @@ public void testBuiltInOperatorFunctionType_423396() throws Exception { // void foo() { // waldo(__FUNCTION__); // } + @Test public void testTypeOfBuiltinSymbol_512932() throws Exception { parseAndCheckBindings(); } @@ -11735,6 +12292,7 @@ public void testTypeOfBuiltinSymbol_512932() throws Exception { // S s; // tint(s.S); // } + @Test public void testFieldWithSameNameAsClass_326750() throws Exception { parseAndCheckBindings(); } @@ -11744,11 +12302,13 @@ public void testFieldWithSameNameAsClass_326750() throws Exception { // int main() { // waldo([](){}); // } + @Test public void testConversionFromLambdaToFunctionPointer_424765() throws Exception { parseAndCheckBindings(); } // void bar(void *a1, void *a2) __attribute__((nonnull(1, 2))); + @Test public void testGCCAttributeSequence_416430() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); IASTDeclaration[] declarations = tu.getDeclarations(); @@ -11782,11 +12342,13 @@ public void testGCCAttributeSequence_416430() throws Exception { // struct MyStruct::Inner in; // in.waldo; // } + @Test public void testFieldAndNestedTypeWithSameName_425033() throws Exception { parseAndCheckBindings(); } // void f(double (&(x))); + @Test public void testParenthesizedReferenceArgument_424898() throws Exception { parseAndCheckBindings(); } @@ -11798,6 +12360,7 @@ public void testParenthesizedReferenceArgument_424898() throws Exception { // } // // constexpr int waldo = naive_fibonacci(5); + @Test public void testConditionalExpressionFolding_429891() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable waldo = helper.assertNonProblem("waldo"); @@ -11811,6 +12374,7 @@ public void testConditionalExpressionFolding_429891() throws Exception { // } // // constexpr int waldo = naive_fibonacci(50); + @Test public void testConstexprEvaluationLimit_429891() throws Exception { // Here we're just checking that the computation of the initial // value finishes (with a null result) in a reasonable time. @@ -11825,6 +12389,7 @@ public void testConstexprEvaluationLimit_429891() throws Exception { // return a; // } // constexpr int waldo = foo(); + @Test public void testNameLookupInDefaultArgument_432701() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable waldo = helper.assertNonProblem("waldo"); @@ -11838,6 +12403,7 @@ public void testNameLookupInDefaultArgument_432701() throws Exception { // S1(42); // s2(43); // } + @Test public void testICPPASTFunctionCallExpression_getOverload_441701() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -11851,6 +12417,7 @@ public void testICPPASTFunctionCallExpression_getOverload_441701() throws Except } // void f(int &&a); + @Test public void testRValueReferenceSignature_427856() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); IASTSimpleDeclaration sd = (IASTSimpleDeclaration) tu.getDeclarations()[0]; @@ -11863,12 +12430,14 @@ public void testRValueReferenceSignature_427856() throws Exception { // int waldo = 42; // find(waldo); // } + @Test public void testRValueReferenceBindingToTemporary_470943() throws Exception { parseAndCheckBindings(); } // constexpr int waldo1 = 42; // constexpr auto waldo2 = 43; + @Test public void testConstexprVariableIsConst_451091() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPVariable waldo1 = helper.assertNonProblem("waldo1"); @@ -11879,6 +12448,7 @@ public void testConstexprVariableIsConst_451091() throws Exception { } // constexpr int* waldo; + @Test public void testConstexprPointerVariable_541670() throws Exception { getAssertionHelper().assertVariableType("waldo", CommonCPPTypes.constPointerToInt); } @@ -11886,6 +12456,7 @@ public void testConstexprPointerVariable_541670() throws Exception { // constexpr int waldo1(); // constexpr int (*waldo2())(int); // struct S { constexpr int waldo3(); }; + @Test public void testTypeOfConstexprFunction_451090() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction waldo1 = helper.assertNonProblem("waldo1"); @@ -11900,12 +12471,14 @@ public void testTypeOfConstexprFunction_451090() throws Exception { } // void waldo() noexcept; + @Test public void testASTCopyForNoexceptDefault_bug456207() throws Exception { parseAndCheckBindings(); } // template struct waldo { waldo(int); }; // auto x = static_cast>(0); + @Test public void testTemplateIdInsideCastOperator_460080() throws Exception { parseAndCheckBindings(); } @@ -11928,17 +12501,20 @@ public void testTemplateIdInsideCastOperator_460080() throws Exception { // struct Y { // alignas(N...) char x; // }; + @Test public void testAlignas_451082() throws Exception { parseAndCheckBindings(); } // struct alignas(16) Node {}; // enum alignas(8) E { E1, E2 }; + @Test public void testAlignas_475739() throws Exception { parseAndCheckBindings(); } // __attribute__((section(".example"))) alignas(4) static int waldo; + @Test public void testAlignasAfterAttribute_538615() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } @@ -11946,6 +12522,7 @@ public void testAlignasAfterAttribute_538615() throws Exception { // int var1 alignas(16); // int var2 __attribute__((section(".example"))) alignas(16); // int var3 alignas(16) __attribute__((section(".example"))); + @Test public void testAlignaAsAfterDeclarator() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } @@ -11958,6 +12535,7 @@ public void testAlignaAsAfterDeclarator() throws Exception { // int operator "" _F(const char32_t* s, unsigned int sz) { return sz; } // int operator "" _G(char c) { return (int)c; } // constexpr double operator "" _km_to_miles(long double km) { return km * 0.6213; } + @Test public void testSimpleUserDefinedLiteralOperators() throws Exception { parseAndCheckBindings(); } @@ -11994,6 +12572,7 @@ public void testSimpleUserDefinedLiteralOperators() throws Exception { // 01_suff, // 1ULL << 34, // }; + @Test public void testIntegerUserDefinedLiterals() throws Exception { parseAndCheckBindings(); } @@ -12007,6 +12586,7 @@ public void testIntegerUserDefinedLiterals() throws Exception { // 0x01p3XX, // 1._X // }; + @Test public void testDoublesUserDefinedLiterals() throws Exception { parseAndCheckBindings(); } @@ -12015,6 +12595,7 @@ public void testDoublesUserDefinedLiterals() throws Exception { // char c2 = '0'suff; // char* c3 = "Hello"_suff; // char* c4 = "Hello"suff; + @Test public void testCharStringUserDefinedLiterals() throws Exception { parseAndCheckBindings(); } @@ -12022,6 +12603,7 @@ public void testCharStringUserDefinedLiterals() throws Exception { // class Ret {}; // Ret operator "" _X(unsigned long long i) { return Ret(); } // auto test = 123_X; + @Test public void testUserDefinedLiteralOperatorTypes1() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12029,6 +12611,7 @@ public void testUserDefinedLiteralOperatorTypes1() throws Exception { // class Ret {}; // Ret operator "" _X(long double i) { return Ret(); } // auto test = 12.3_X; + @Test public void testUserDefinedLiteralOperatorTypes2() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12036,6 +12619,7 @@ public void testUserDefinedLiteralOperatorTypes2() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s) { return Ret(); } // auto test = 123_X; + @Test public void testUserDefinedLiteralOperatorTypes1a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12043,6 +12627,7 @@ public void testUserDefinedLiteralOperatorTypes1a() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s) { return Ret(); } // auto test = 12.3_X; + @Test public void testUserDefinedLiteralOperatorTypes2a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12051,6 +12636,7 @@ public void testUserDefinedLiteralOperatorTypes2a() throws Exception { // Ret operator "" _X(unsigned long long d) { return Ret(); } // bool operator "" _X(const char* s) { return false; } // auto test = 123_X; + @Test public void testUserDefinedLiteralOperatorTypes1b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12059,6 +12645,7 @@ public void testUserDefinedLiteralOperatorTypes1b() throws Exception { // Ret operator "" _X(long double d) { return Ret(); } // bool operator "" _X(const char* s) { return false; } // auto test = 12.3_X; + @Test public void testUserDefinedLiteralOperatorTypes2b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12066,6 +12653,7 @@ public void testUserDefinedLiteralOperatorTypes2b() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralOperatorTypes3() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12073,6 +12661,7 @@ public void testUserDefinedLiteralOperatorTypes3() throws Exception { // class Ret {}; // Ret operator "" _X(const wchar_t* s, unsigned sz) { return Ret(); } // auto test = L"123"_X; + @Test public void testUserDefinedLiteralOperatorTypes3a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12080,6 +12669,7 @@ public void testUserDefinedLiteralOperatorTypes3a() throws Exception { // class Ret {}; // Ret operator "" _X(const char16_t* s, unsigned sz) { return Ret(); } // auto test = u"123"_X; + @Test public void testUserDefinedLiteralOperatorTypes3b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12087,6 +12677,7 @@ public void testUserDefinedLiteralOperatorTypes3b() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = U"123"_X; + @Test public void testUserDefinedLiteralOperatorTypes3c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12094,6 +12685,7 @@ public void testUserDefinedLiteralOperatorTypes3c() throws Exception { // class Ret {}; // template Ret operator "" _X() { return Ret(); } // auto test = 123_X; + @Test public void testUserDefinedLiteralOperatorTypes4a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12101,6 +12693,7 @@ public void testUserDefinedLiteralOperatorTypes4a() throws Exception { // class Ret {}; // template Ret operator "" _X() { return Ret(); } // auto test = 123.123_X; + @Test public void testUserDefinedLiteralOperatorTypes4b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12108,6 +12701,7 @@ public void testUserDefinedLiteralOperatorTypes4b() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = "123" "123"_X; + @Test public void testUserDefinedLiteralConcatenation1a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12115,6 +12709,7 @@ public void testUserDefinedLiteralConcatenation1a() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = "123"_X "123"; + @Test public void testUserDefinedLiteralConcatenation1b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12122,6 +12717,7 @@ public void testUserDefinedLiteralConcatenation1b() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = u8"123" "123"_X; + @Test public void testUserDefinedLiteralConcatenation2a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12129,6 +12725,7 @@ public void testUserDefinedLiteralConcatenation2a() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = u8"123"_X "123"; + @Test public void testUserDefinedLiteralConcatenation2b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12136,6 +12733,7 @@ public void testUserDefinedLiteralConcatenation2b() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = "123" u8"123"_X; + @Test public void testUserDefinedLiteralConcatenation2c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12143,6 +12741,7 @@ public void testUserDefinedLiteralConcatenation2c() throws Exception { // class Ret {}; // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // auto test = "123"_X u8"123"; + @Test public void testUserDefinedLiteralConcatenation2d() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12150,6 +12749,7 @@ public void testUserDefinedLiteralConcatenation2d() throws Exception { // class Ret {}; // Ret operator "" _X(const wchar_t* s, unsigned sz) { return Ret(); } // auto test = L"123" "123"_X; + @Test public void testUserDefinedLiteralConcatenation3a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12157,6 +12757,7 @@ public void testUserDefinedLiteralConcatenation3a() throws Exception { // class Ret {}; // Ret operator "" _X(const wchar_t* s, unsigned sz) { return Ret(); } // auto test = L"123"_X "123"; + @Test public void testUserDefinedLiteralConcatenation3b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12164,6 +12765,7 @@ public void testUserDefinedLiteralConcatenation3b() throws Exception { // class Ret {}; // Ret operator "" _X(const wchar_t* s, unsigned sz) { return Ret(); } // auto test = "123" L"123"_X; + @Test public void testUserDefinedLiteralConcatenation3c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12171,6 +12773,7 @@ public void testUserDefinedLiteralConcatenation3c() throws Exception { // class Ret {}; // Ret operator "" _X(const wchar_t* s, unsigned sz) { return Ret(); } // auto test = "123"_X L"123"; + @Test public void testUserDefinedLiteralConcatenation3d() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12178,6 +12781,7 @@ public void testUserDefinedLiteralConcatenation3d() throws Exception { // class Ret {}; // Ret operator "" _X(const char16_t* s, unsigned sz) { return Ret(); } // auto test = u"123" "123"_X; + @Test public void testUserDefinedLiteralConcatenation4a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12185,6 +12789,7 @@ public void testUserDefinedLiteralConcatenation4a() throws Exception { // class Ret {}; // Ret operator "" _X(const char16_t* s, unsigned sz) { return Ret(); } // auto test = u"123"_X "123"; + @Test public void testUserDefinedLiteralConcatenation4b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12192,6 +12797,7 @@ public void testUserDefinedLiteralConcatenation4b() throws Exception { // class Ret {}; // Ret operator "" _X(const char16_t* s, unsigned sz) { return Ret(); } // auto test = "123" u"123"_X; + @Test public void testUserDefinedLiteralConcatenation4c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12199,6 +12805,7 @@ public void testUserDefinedLiteralConcatenation4c() throws Exception { // class Ret {}; // Ret operator "" _X(const char16_t* s, unsigned sz) { return Ret(); } // auto test = "123"_X u"123"; + @Test public void testUserDefinedLiteralConcatenation4d() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12206,6 +12813,7 @@ public void testUserDefinedLiteralConcatenation4d() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = U"123" "123"_X; + @Test public void testUserDefinedLiteralConcatenation5a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12213,6 +12821,7 @@ public void testUserDefinedLiteralConcatenation5a() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = U"123"_X "123"; + @Test public void testUserDefinedLiteralConcatenation5b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12220,6 +12829,7 @@ public void testUserDefinedLiteralConcatenation5b() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = "123" U"123"_X; + @Test public void testUserDefinedLiteralConcatenation5c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12227,6 +12837,7 @@ public void testUserDefinedLiteralConcatenation5c() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = "123"_X U"123"; + @Test public void testUserDefinedLiteralConcatenation5d() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12234,6 +12845,7 @@ public void testUserDefinedLiteralConcatenation5d() throws Exception { // class Ret {}; // Ret operator "" _X(const char32_t* s, unsigned sz) { return Ret(); } // auto test = "123"_X U"123"_X; + @Test public void testUserDefinedLiteralConcatenation6() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12241,6 +12853,7 @@ public void testUserDefinedLiteralConcatenation6() throws Exception { // class Ret {}; // Ret operator "" _X(char const * const s, unsigned long sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_1a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12248,6 +12861,7 @@ public void testUserDefinedLiteralConcatenation_528196_1a() throws Exception { // class Ret {}; // Ret operator "" _X(char const * volatile s, unsigned long sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_1b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12255,6 +12869,7 @@ public void testUserDefinedLiteralConcatenation_528196_1b() throws Exception { // class Ret {}; // Ret operator "" _X(char const * const volatile s, unsigned long sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_1c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12262,6 +12877,7 @@ public void testUserDefinedLiteralConcatenation_528196_1c() throws Exception { // class Ret {}; // Ret operator "" _X(char const * s, unsigned long const sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_2a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12269,6 +12885,7 @@ public void testUserDefinedLiteralConcatenation_528196_2a() throws Exception { // class Ret {}; // Ret operator "" _X(char const * s, unsigned long volatile sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_2b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12276,6 +12893,7 @@ public void testUserDefinedLiteralConcatenation_528196_2b() throws Exception { // class Ret {}; // Ret operator "" _X(char const * s, unsigned long const volatile sz) { return Ret(); } // auto test = "123"_X; + @Test public void testUserDefinedLiteralConcatenation_528196_2c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12283,6 +12901,7 @@ public void testUserDefinedLiteralConcatenation_528196_2c() throws Exception { // class Ret {}; // Ret operator "" _X(unsigned long long const) { return Ret(); } // auto test = 10_X; + @Test public void testUserDefinedLiteralConcatenation_528196_3a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12290,6 +12909,7 @@ public void testUserDefinedLiteralConcatenation_528196_3a() throws Exception { // class Ret {}; // Ret operator "" _X(unsigned long long volatile) { return Ret(); } // auto test = 10_X; + @Test public void testUserDefinedLiteralConcatenation_528196_3b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12297,6 +12917,7 @@ public void testUserDefinedLiteralConcatenation_528196_3b() throws Exception { // class Ret {}; // Ret operator "" _X(unsigned long long const volatile) { return Ret(); } // auto test = 10_X; + @Test public void testUserDefinedLiteralConcatenation_528196_3c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12304,6 +12925,7 @@ public void testUserDefinedLiteralConcatenation_528196_3c() throws Exception { // class Ret {}; // Ret operator "" _X(char const) { return Ret(); } // auto test = 'a'_X; + @Test public void testUserDefinedLiteralConcatenation_528196_4a() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12311,6 +12933,7 @@ public void testUserDefinedLiteralConcatenation_528196_4a() throws Exception { // class Ret {}; // Ret operator "" _X(char volatile) { return Ret(); } // auto test = 'a'_X; + @Test public void testUserDefinedLiteralConcatenation_528196_4b() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12318,6 +12941,7 @@ public void testUserDefinedLiteralConcatenation_528196_4b() throws Exception { // class Ret {}; // Ret operator "" _X(char const volatile) { return Ret(); } // auto test = 'a'_X; + @Test public void testUserDefinedLiteralConcatenation_528196_4c() throws Exception { checkUserDefinedLiteralIsRet(getAboveComment()); } @@ -12326,6 +12950,7 @@ public void testUserDefinedLiteralConcatenation_528196_4c() throws Exception { // Ret operator "" _X(const char* s, unsigned sz) { return Ret(); } // Ret operator "" _Y(const char* s, unsigned sz) { return Ret(); } // auto test = "123"_X "123"_Y; + @Test public void testUserDefinedLiteralBadConcatenation1() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, false); @@ -12342,16 +12967,19 @@ public void testUserDefinedLiteralBadConcatenation1() throws Exception { // return basic_string { str, len }; // } // auto waldo = "Waldo"s; + @Test public void testStringLiterals() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "basic_string"); } // auto waldo = 1i + 1; + @Test public void testComplexNumbersCompilerSupport1() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "_Complex int"); } // auto waldo = 1j + 1; + @Test public void testComplexNumbersCompilerSupport2() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "_Complex int"); } @@ -12364,6 +12992,7 @@ public void testComplexNumbersCompilerSupport2() throws Exception { // return complex { 0, imag }; // } // auto waldo = 1i + 1; + @Test public void testComplexNumbersOverriddenCompilerSupport() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "complex"); } @@ -12376,6 +13005,7 @@ public void testComplexNumbersOverriddenCompilerSupport() throws Exception { // return complex { 0, imag }; // } // auto waldo = 1.0if + 1; + @Test public void testComplexFloatNumbersOverriddenCompilerSupport() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "complex"); } @@ -12383,6 +13013,7 @@ public void testComplexFloatNumbersOverriddenCompilerSupport() throws Exception // // Test name lacking a space // int operator ""X(const char* s) { return 0; } // int operator ""_X(const char* s) { return 0; } + @Test public void testUserDefinedLiteralNoWhiteSpace1() throws Exception { parseAndCheckBindings(); } @@ -12407,6 +13038,7 @@ public void testUserDefinedLiteralNoWhiteSpace1() throws Exception { // auto e4 = u"1" _X "2"; // auto e5 = U"1" _X "2"; // auto d5 = U"1" _X; + @Test public void testUserDefinedLiteralNoWhiteSpace2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, false); IASTDeclaration[] decls = tu.getDeclarations(); @@ -12423,6 +13055,7 @@ public void testUserDefinedLiteralNoWhiteSpace2() throws Exception { // template RetA operator "" _X() { return RetA(); } // RetB operator "" _X(unsigned long long i) { return RetB(); } // auto a = 123_X; + @Test public void testUserDefinedLiteralResolution1() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "RetB"); } @@ -12432,6 +13065,7 @@ public void testUserDefinedLiteralResolution1() throws Exception { // template RetA operator "" _X() { return RetA(); } // RetB operator "" _X(long double i) { return RetB(); } // auto a = 123.123_X; + @Test public void testUserDefinedLiteralResolution2() throws Exception { checkUserDefinedLiteralIsType(getAboveComment(), "RetB"); } @@ -12441,6 +13075,7 @@ public void testUserDefinedLiteralResolution2() throws Exception { // template RetA operator "" _X() { return RetA(); } // RetB operator "" _X(const char * c) { return RetB(); } // auto test = 123_X; + @Test public void testUserDefinedLiteralResolution3() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPVariable test = bh.assertNonProblemOnFirstIdentifier("test"); @@ -12456,6 +13091,7 @@ public void testUserDefinedLiteralResolution3() throws Exception { // using namespace N; // setColor("#ffffff"_color); // ERROR // } + @Test public void testUserDefinedLiteralInNamespace_510665() throws Exception { parseAndCheckBindings(); } @@ -12464,6 +13100,7 @@ public void testUserDefinedLiteralInNamespace_510665() throws Exception { // double waldo2 = 09.268; // double waldo3 = 02e2; // double waldo4 = 09e2; + @Test public void testFloatLiteralWithLeadingZero_498434() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -12471,6 +13108,7 @@ public void testFloatLiteralWithLeadingZero_498434() throws Exception { // char foo() { // return '*'; // } + @Test public void testRegression_484618() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -12488,6 +13126,7 @@ public void testRegression_484618() throws Exception { // #else // 0; // #endif + @Test public void testHasFeature_442325() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("lambdas_supported", 1); @@ -12509,6 +13148,7 @@ public void testHasFeature_442325() throws Exception { // int c[6] = { [4] = 29, [2] = 15 }; // int d[6] = { [2 ... 4] = 29 }; // } + @Test public void testDesignatedInitializers() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); // ICPPASTDesignatedInitializer d1 = bh.assertNode(".a = 10"); @@ -12562,6 +13202,7 @@ public void testDesignatedInitializers() throws Exception { // struct F : D, virtual E { // F() {} // }; + @Test public void testImplicitlyCalledBaseConstructor_393717() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -12599,6 +13240,7 @@ public void testImplicitlyCalledBaseConstructor_393717() throws Exception { // int main() { // a(A{3, 4}); // } + @Test public void testImplicitConstructorNameInTypeConstructorExpression_447431() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPConstructor ctor = helper.assertNonProblem("A(int, int)", "A"); @@ -12617,6 +13259,7 @@ public void testImplicitConstructorNameInTypeConstructorExpression_447431() thro // using Waldo = Waldo; // auto size = sizeof(Waldo::x); // } + @Test public void testShadowingAliasDeclaration_484200() throws Exception { parseAndCheckBindings(); } @@ -12628,6 +13271,7 @@ public void testShadowingAliasDeclaration_484200() throws Exception { // return Zero == 0; // "Symbol 'Zero' could not be resolved" // } // }; + @Test public void testAnonymousEnumInAliasDeclaration_502016() throws Exception { parseAndCheckBindings(); } @@ -12639,6 +13283,7 @@ public void testAnonymousEnumInAliasDeclaration_502016() throws Exception { // enum class E { A }; // void bar(E); // }; + @Test public void testEnumDeclaredLaterInClass_491747() throws Exception { parseAndCheckBindings(); } @@ -12648,6 +13293,7 @@ public void testEnumDeclaredLaterInClass_491747() throws Exception { // return 5; // } // constexpr int waldo = A + A; + @Test public void testOverloadedOperatorWithEnumArgument_506672() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 5); @@ -12657,6 +13303,7 @@ public void testOverloadedOperatorWithEnumArgument_506672() throws Exception { // static S waldo; // }; // void foo(const S& = S()); + @Test public void testValueRepresentationOfClassWithStaticMemberOfOwnType_490475() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction foo = helper.assertNonProblem("foo"); @@ -12668,6 +13315,7 @@ public void testValueRepresentationOfClassWithStaticMemberOfOwnType_490475() thr // S waldo; // invalid // }; // void foo(const S& = S()); + @Test public void testClassDirectlyAggregatingItself_490475() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction foo = helper.assertNonProblem("foo"); @@ -12683,6 +13331,7 @@ public void testClassDirectlyAggregatingItself_490475() throws Exception { // S waldo; // }; // void foo(const T& = T()); + @Test public void testClassIndirectlyAggregatingItself_490475() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPFunction foo = helper.assertNonProblem("foo"); @@ -12709,6 +13358,7 @@ public void testClassIndirectlyAggregatingItself_490475() throws Exception { // decltype(auto) const m = 42; // Error - decltype(auto) does not allow type specifiers. Bug 527553 // decltype(auto) volatile n = 42; // Error - decltype(auto) does not allow type specifiers. Bug 527553 // decltype(auto) const volatile o = 42; // Error - decltype(auto) does not allow type specifiers. Bug 527553 + @Test public void testDecltypeAutoVariableTypes_482225() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -12765,6 +13415,7 @@ public void testDecltypeAutoVariableTypes_482225() throws Exception { // return 23.0; // } // auto a = foo(); + @Test public void testDecltypeAutoTrailingReturnTypeConst_527553() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -12777,6 +13428,7 @@ public void testDecltypeAutoTrailingReturnTypeConst_527553() throws Exception { // return 23.0; // } // auto a = foo(); + @Test public void testDecltypeAutoTrailingReturnTypeVolatile_527553() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -12789,6 +13441,7 @@ public void testDecltypeAutoTrailingReturnTypeVolatile_527553() throws Exception // return 23.0; // } // decltype(auto) a = foo(); + @Test public void testDecltypeAutoTrailingReturnTypeConstDecltype_527553() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -12800,6 +13453,7 @@ public void testDecltypeAutoTrailingReturnTypeConstDecltype_527553() throws Exce // auto foo() -> decltype(auto) { // return 23.0; // } + @Test public void testDecltypeAutoTrailingReturnType_482225() throws Exception { parseAndCheckBindings(); } @@ -12807,6 +13461,7 @@ public void testDecltypeAutoTrailingReturnType_482225() throws Exception { // decltype(auto) foo() { // return 23.0; // } + @Test public void testDecltypeAutoReturnType_482225() throws Exception { parseAndCheckBindings(); } @@ -12819,11 +13474,13 @@ public void testDecltypeAutoReturnType_482225() throws Exception { // Waldo w; // auto i1 = w, i2 = i1.foo(); // Error on 'foo' // } + @Test public void testAutoWithTwoDeclarators_522066() throws Exception { parseAndCheckBindings(); } // constexpr int waldo = (sizeof(double) % 16); + @Test public void testSizeofDouble_506170() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 8); @@ -12838,6 +13495,7 @@ public void testSizeofDouble_506170() throws Exception { // bc || bc; // !bc; // } + @Test public void testContextualBooleanConversion_506972() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); IASTDeclaration explicitBooleanContextsFunction = tu.getDeclarations()[1]; @@ -12872,11 +13530,13 @@ public void testContextualBooleanConversion_506972() throws Exception { // el0 __attribute__((deprecated)), // el1, // }; + @Test public void testEnumeratorAttribute_514821() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); } // void foo([[maybe_unused]] int a); + @Test public void testCxx11AttributeBeforeParameterDeclaration_530729() throws Exception { parseAndCheckBindings(); } @@ -12891,6 +13551,7 @@ public void testCxx11AttributeBeforeParameterDeclaration_530729() throws Excepti // char name[sizeof(CType().m_Array)]; // foo(name); // } + @Test public void testSizeofArrayField_512932() throws Exception { parseAndCheckBindings(); } @@ -12911,6 +13572,7 @@ public void testSizeofArrayField_512932() throws Exception { // //TestNameSpace::TestNameSpace() { //} + @Test public void testUsingDirectiveNamespaceWithPreviousFunctionName_517402() throws Exception { parseAndCheckBindings(); } @@ -12929,6 +13591,7 @@ public void testUsingDirectiveNamespaceWithPreviousFunctionName_517402() throws //namespace ns12 = ns2; //ns12::TestNameSpace::TestNameSpace() { //} + @Test public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws Exception { parseAndCheckBindings(); } @@ -12936,6 +13599,7 @@ public void testNamespaceAliasNamespaceWithPreviousFunctionName_517402() throws // class C {}; // typedef C D; // constexpr bool waldo = __is_class(D); + @Test public void testIsClassBuiltinOnTypedef_522509() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 1); @@ -12943,6 +13607,7 @@ public void testIsClassBuiltinOnTypedef_522509() throws Exception { // struct A {}; // struct A* b = (1 == 1) ? new struct A : new struct A; + @Test public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception { parseAndCheckBindings(); } @@ -12953,6 +13618,7 @@ public void test_ElabTypeSpecInNewExprInConditional_526134() throws Exception { // constexpr bool waldo3 = __is_trivially_constructible(S, const S&); // constexpr bool waldo4 = __is_trivially_constructible(S, int); // constexpr bool waldo5 = __is_trivially_constructible(S, const S&, float); + @Test public void testIsTriviallyConstructible_528072() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo1", 1); @@ -12969,12 +13635,14 @@ public void testIsTriviallyConstructible_528072() throws Exception { // }; // // constexpr bool waldo = __is_constructible(pair, pair&&); + @Test public void testIsConstructible_539052() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 1); } // constexpr bool waldo = unsigned(-1) < unsigned(0); + @Test public void testNegativeCastToUnsigned_544509() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 0); @@ -12989,6 +13657,7 @@ public void testNegativeCastToUnsigned_544509() throws Exception { // constexpr short short_from_negative_long = -((1L << 32) + 1); // constexpr unsigned int uint_from_negative_long = -((1L << 32) + 1); // constexpr unsigned short ushort_from_negative_long = -((1L << 32) + 1); + @Test public void testIntegerImplicitConversions() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -13009,6 +13678,7 @@ public void testIntegerImplicitConversions() throws Exception { // constexpr bool bool_from_int_expr = int(0x100000001L) < 2; // constexpr bool bool_from_short_expr = short(0x100010001L) < 2; // constexpr int int_from_cast_to_int = (int)((1L << 32) + 1); + @Test public void testIntegerTrunctatingConversions() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("bool_from_int_positive", 1); @@ -13027,6 +13697,7 @@ public void testIntegerTrunctatingConversions() throws Exception { // constexpr unsigned int uint_from_uint_literal_negation = -(1U); // constexpr unsigned int uint_from_uint_cast_negation = -(1U); // constexpr unsigned short ushort_from_ushort_cast_negation = -((unsigned short)1); + @Test public void testUnsignedIntegerUnaryMinus() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); @@ -13051,6 +13722,7 @@ public void testUnsignedIntegerUnaryMinus() throws Exception { // int main() { // x::y::bar(); // } + @Test public void testNestedNamespaceDefinition_490359() throws Exception { parseAndCheckBindings(); } @@ -13062,6 +13734,7 @@ public void testNestedNamespaceDefinition_490359() throws Exception { // auto v_a = 1'123'456ul; // auto v_b = 1'123'456ull; // auto v_c = 0xAABB'CCDDll; + @Test public void testLiteralDecimalSeparators_519062() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("l_a", 804); @@ -13078,6 +13751,7 @@ public void testLiteralDecimalSeparators_519062() throws Exception { // extern void *List[]; // void *List[] = { 0 }; // unsigned int ListSize = sizeof(List)/sizeof(List[0]); + @Test public void testMultipleExternDecls_534098() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable var = helper.assertNonProblem("ListSize"); @@ -13087,6 +13761,7 @@ public void testMultipleExternDecls_534098() throws Exception { } //static_assert(true); + @Test public void testStaticAssertWithoutMessage_534808() throws Exception { parseAndCheckBindings(); } @@ -13098,6 +13773,7 @@ public void testStaticAssertWithoutMessage_534808() throws Exception { // auto myFunA() -> struct MyStruct { // return {5}; // }; + @Test public void testElabSpecInTrailingReturn_535777() throws Exception { parseAndCheckBindings(); } @@ -13114,6 +13790,7 @@ public void testElabSpecInTrailingReturn_535777() throws Exception { // type a4{1,2,3}; // type a5 = {1,2,3}; // } + @Test public void testInitListConstructor_542448() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("a0", 2, CPPConstructor.class); @@ -13134,6 +13811,7 @@ public void testInitListConstructor_542448() throws Exception { // type a1{1,2}; // ok // type a2 = {1,2}; // error: using explict ctor // } + @Test public void testInitListConstructorWithExplicit_542448() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("a0", 2, CPPConstructor.class); @@ -13148,6 +13826,7 @@ public void testInitListConstructorWithExplicit_542448() throws Exception { // int main() { // type a0 = {1,2}; // } + @Test public void testInitListConstructorWithExplicit2_542448() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); // ill-formed, because overload resolution @@ -13166,6 +13845,7 @@ public void testInitListConstructorWithExplicit2_542448() throws Exception { // }; // // A a{1, 3, 5, 6}; + @Test public void testInitListConstRef_549035() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13181,6 +13861,7 @@ public void testInitListConstRef_549035() throws Exception { // type{1, 2}; // type(other_type()); // } + @Test public void testCtorWithWrongArguments_543913() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("type(1, 2)", 4, IProblemBinding.class); @@ -13201,6 +13882,7 @@ public void testCtorWithWrongArguments_543913() throws Exception { // foo({1}); // foo({{1}}); // } + @Test public void testBraceElisionForAggregateInit0_SimpleValid_543038() throws Exception { parseAndCheckBindings(); } @@ -13218,6 +13900,7 @@ public void testBraceElisionForAggregateInit0_SimpleValid_543038() throws Except // foo({1,2}); // foo({{1,2}}); // } + @Test public void testBraceElisionForAggregateInit1_SimpleTooManyInitializers_543038() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("array{{1,2}}", 5, IProblemBinding.class); @@ -13251,6 +13934,7 @@ public void testBraceElisionForAggregateInit1_SimpleTooManyInitializers_543038() // level1{1,2}; // ERROR: calling level1 constructor, not aggregate init of level0 // foo({{{1,2,3}}}); // ERROR: not aggregate init // } + @Test public void testBraceElisionForAggregateInit2_WithNonAggregate_543038() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("foo({level1{{1,2}}})", 3); @@ -13272,6 +13956,7 @@ public void testBraceElisionForAggregateInit2_WithNonAggregate_543038() throws E // foo({1,2,3,1,2,3}); // eliding all levels // foo({{1,2,3},{1,2,3}}); // ERROR eliding outer-most is not allowed // } + @Test public void testBraceElisionForAggregateInit3_543038() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("foo({{{1,2,3},{1,2,3}}});", 3); @@ -13295,6 +13980,7 @@ public void testBraceElisionForAggregateInit3_543038() throws Exception { // foo({type{1},type{2}}); // foo({type{1}}); // ERROR: type is not default constructible // } + @Test public void testBraceElisionForAggregateInit4_nonDefaultConstructible_543038() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("foo({type{1},type{2}});", 3); @@ -13312,6 +13998,7 @@ public void testBraceElisionForAggregateInit4_nonDefaultConstructible_543038() t // foo({{1,2,3,{1,2,3}}}); // ok: data[1] is initialized without elision, data[0] with elision // foo({{1,2,{1,2,3}}}); // ERROR: trying to initialize data[0][2] with {1,2,3} // } + @Test public void testBraceElisionForAggregateInit5_partlyEliding_543038() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("foo({{{1,2,3},1,2,3}});", 3); @@ -13335,6 +14022,7 @@ public void testBraceElisionForAggregateInit5_partlyEliding_543038() throws Exce // int main() { // foo({1}); // } + @Test public void testBraceElisionForAggregateInit6_typedef_543038() throws Exception { parseAndCheckBindings(); } @@ -13348,6 +14036,7 @@ public void testBraceElisionForAggregateInit6_typedef_543038() throws Exception // auto s1 = S1 { }; // return S2 { s1 }; // } + @Test public void testBraceElisionForAggregateInit7_545957() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13356,6 +14045,7 @@ public void testBraceElisionForAggregateInit7_545957() throws Exception { // int a; // }; // type b{sizeof(type)}; + @Test public void testAggregateInitNoNarrowingConversionInConstContext_545756() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13368,6 +14058,7 @@ public void testAggregateInitNoNarrowingConversionInConstContext_545756() throws // struct B { // A a{sizeof(T)}; // }; + @Test public void testAggregateInitNoNarrowingConversionInDependentConstContext_545756() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13377,6 +14068,7 @@ public void testAggregateInitNoNarrowingConversionInDependentConstContext_545756 // }; // const unsigned long v = 1; // type b{v}; + @Test public void testAggregateInitNoNarrowingConversionInConstContext2_545756() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13386,6 +14078,7 @@ public void testAggregateInitNoNarrowingConversionInConstContext2_545756() throw // }; // unsigned long v = 1; // type b{v}; + @Test public void testAggregateInitNarrowingConversion_545756() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("b{v};", 1, IProblemBinding.class); @@ -13397,6 +14090,7 @@ public void testAggregateInitNarrowingConversion_545756() throws Exception { // }; // // type foo{"s"}; + @Test public void testCharArrayInitFromStringLiteral_545756() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13406,6 +14100,7 @@ public void testCharArrayInitFromStringLiteral_545756() throws Exception { // }; // // type foo{"big"}; + @Test public void testCharArrayInitFromTooLargeStringLiteral_545756() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("foo", 3, IProblemBinding.class); @@ -13416,6 +14111,7 @@ public void testCharArrayInitFromTooLargeStringLiteral_545756() throws Exception // }; // // type foo{L"s"}; + @Test public void testCharArrayInitFromWrongTypeStringLiteral_545756() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("foo", 3, IProblemBinding.class); @@ -13426,6 +14122,7 @@ public void testCharArrayInitFromWrongTypeStringLiteral_545756() throws Exceptio // }; // // type foo{"s"}; + @Test public void testUnknownSizeCharArrayInitFromStringLiteral_545756() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertImplicitName("foo", 3, IProblemBinding.class); @@ -13443,6 +14140,7 @@ public void testUnknownSizeCharArrayInitFromStringLiteral_545756() throws Except // Time time = t.get(); // } // }; + @Test public void testCopyInitializationFromDependentType_546843() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13460,6 +14158,7 @@ public void testCopyInitializationFromDependentType_546843() throws Exception { // Time time{t.get()}; // } // }; + @Test public void testListInitializationFromDependentType_546843() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13483,6 +14182,7 @@ public void testListInitializationFromDependentType_546843() throws Exception { // constexpr bool fptr_is_not_noexcept = noexcept(fptr()); // constexpr bool fptr_noexcept_is_noexcept = noexcept(fptr_noexcept()); // constexpr bool throw_is_not_noexcept = noexcept(throw fun_noexcept()); + @Test public void testNoexceptOperatorFunctions_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13507,6 +14207,7 @@ public void testNoexceptOperatorFunctions_545021() throws Exception { // constexpr bool not_noexcept_conditional = noexcept(noexcept_condition() ? fun() : fun_noexcept()); // constexpr bool is_noexcept_conditional = noexcept(noexcept_condition() ? fun_noexcept() : fun_noexcept()); // constexpr bool condition_not_noexcept = noexcept(condition() ? fun_noexcept() : fun_noexcept()); + @Test public void testNoexceptOperatorOperators_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13524,6 +14225,7 @@ public void testNoexceptOperatorOperators_545021() throws Exception { // // constexpr bool aggregate_init_is_noexcept = noexcept(aggregate{1}); // constexpr bool aggregate_access_is_noexcept = noexcept(agg.a); + @Test public void testNoexceptOperatorAggregate_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13539,6 +14241,7 @@ public void testNoexceptOperatorAggregate_545021() throws Exception { // constexpr bool ctor_is_noexcept = noexcept(myclass{}); // constexpr bool ctor_is_not_noexcept = noexcept(myclass{1}); // constexpr bool constexpr_ctor_is_noexcept = noexcept(myclass{1, 1}); + @Test public void testNoexceptOperatorConstructors_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13567,6 +14270,7 @@ public void testNoexceptOperatorConstructors_545021() throws Exception { // constexpr bool noexcept_conversion = noexcept(static_cast(t)); // constexpr bool not_noexcept_conversion = noexcept(static_cast(t)); // constexpr bool conversion_from_constructor = noexcept(static_cast(type{})); + @Test public void testNoexceptOperatorType_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13590,6 +14294,7 @@ public void testNoexceptOperatorType_545021() throws Exception { // // constexpr bool funt_is_not_noexcept = noexcept(funt(1)); // constexpr bool funt_noexcept_is_noexcept = noexcept(funt_noexcept(1)); + @Test public void testNoexceptOperatorFunctionTemplates_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13611,6 +14316,7 @@ public void testNoexceptOperatorFunctionTemplates_545021() throws Exception { // constexpr bool unaryop_is_not_noexcept = noexcept(!t1); // constexpr bool noexcept_binaryop_is_noexcept = noexcept(t2 = 1); // constexpr bool noexcept_unaryop_is_noexcept = noexcept(!t2); + @Test public void testNoexceptOperatorOverloadedOperators_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13624,6 +14330,7 @@ public void testNoexceptOperatorOverloadedOperators_545021() throws Exception { // void fun_taking_funptr(void(*ptr)()) noexcept; // // constexpr bool is_noexcept = noexcept(fun_taking_funptr(fun)); + @Test public void testNoexceptOperatorNoncalledFunctionPtr_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13632,6 +14339,7 @@ public void testNoexceptOperatorNoncalledFunctionPtr_545021() throws Exception { // void fun() throw(); // constexpr bool is_noexcept = noexcept(fun()); + @Test public void testNoexceptOperatorEmptyThrow_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13643,6 +14351,7 @@ public void testNoexceptOperatorEmptyThrow_545021() throws Exception { // auto closure = [](int i) {return i;}; // constexpr bool is_not_noexcept = noexcept(closure()); // constexpr bool conversion_is_noexcept = noexcept(static_cast(closure)); + @Test public void testNoexceptOperatorLambda_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13656,6 +14365,7 @@ public void testNoexceptOperatorLambda_545021() throws Exception { // // constexpr bool is_noexcept = noexcept(foo()); // constexpr bool is_not_noexcept = noexcept(foo()); + @Test public void testNoexceptOperatorDependentNoexcept_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13666,6 +14376,7 @@ public void testNoexceptOperatorDependentNoexcept_545021() throws Exception { // struct S { int mem; }; // S foo(); // could throw // constexpr bool is_not_noexcept = noexcept(foo().mem); // should be false + @Test public void testNoexceptOperatorOwnerEval_545021() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -13676,6 +14387,7 @@ public void testNoexceptOperatorOwnerEval_545021() throws Exception { // B a; // }; // B t{1}; + @Test public void testSelfAggregation_546805() throws Exception { // Note that ideally we would report an error already on the declaration of B as // the class is aggregating itself. Today, we only report an error because of a @@ -13692,6 +14404,7 @@ public void testSelfAggregation_546805() throws Exception { // A a; // }; // B t{1}; + @Test public void testIndirectSelfAggregation_546805() throws Exception { // See comment in previous test BindingAssertionHelper bh = getAssertionHelper(); @@ -13708,6 +14421,7 @@ public void testIndirectSelfAggregation_546805() throws Exception { // }; // // auto a = A{1, 2}; + @Test public void testClassFromInitList_549036() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -13715,6 +14429,7 @@ public void testClassFromInitList_549036() throws Exception { // int a = 42, b = 42; // float c = 3.14, d = 3.14; // char e[] = "waldo", f[] = "waldo"; + @Test public void testLiteralExpressionEquivalence_551689() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPASTExpression a = helper.assertNode("a = 42", "42"); @@ -13734,6 +14449,7 @@ public void testLiteralExpressionEquivalence_551689() throws Exception { // }; // struct [[nodiscard]] S : public Base { // }; + @Test public void testNoDiscardClass_Bug534420() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -13765,6 +14481,7 @@ public void testNoDiscardClass_Bug534420() throws Exception { //Foo var1; //Foo var2; //Foo var3; + @Test public void testNoDiscardTemplateSpecialization_Bug534420() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -13810,6 +14527,7 @@ public void testNoDiscardTemplateSpecialization_Bug534420() throws Exception { //Foo var1; //Foo var2; //Foo var3; + @Test public void testFinalTemplateSpecialization_Bug561631() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code); @@ -13849,6 +14567,7 @@ public void testFinalTemplateSpecialization_Bug561631() throws Exception { // enum fruit { apple, banana }; // enum hue col; // enum fruit f; + @Test public void testEnumerations_Bug534420() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -13869,6 +14588,7 @@ public void testEnumerations_Bug534420() throws Exception { // // template <> // void waldo(const IntPtr&) {} + @Test public void testExplicitSpecPointerType_562697() throws Exception { parseAndCheckBindings(); } @@ -13939,6 +14659,7 @@ public void testExplicitSpecPointerType_562697() throws Exception { // Test::Value>::false_val; // Test::Value>::true_val; // } + @Test public void testIsSame() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -13970,6 +14691,7 @@ public void testIsSame() throws Exception { // function(true ? 0 : 0); // 12 // functionPtr(true ? 0 : 0); // 13 // } + @Test public void testNullPointerConstantConversion_573764() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector collector = new NameCollector(); @@ -14020,6 +14742,7 @@ public void testNullPointerConstantConversion_573764() throws Exception { // // constexpr auto test_32 = calculate(1, 2); // constexpr auto test_64 = calculate(1, 2); + @Test public void testArithmeticConversionIssue_265() throws Exception { // Depending on size of integer types above it may happen that the rank of unsigned type operand // is less than rank of signed type operand, and both types are of same size. @@ -14034,6 +14757,7 @@ public void testArithmeticConversionIssue_265() throws Exception { } // constexpr auto shiftdouble = (1. << 1); + @Test public void testArithmeticEvaluationWithDoubleShiftOp() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable shiftdouble = helper.assertNonProblem("shiftdouble = ", 11); @@ -14042,6 +14766,7 @@ public void testArithmeticEvaluationWithDoubleShiftOp() throws Exception { } // constexpr auto shiftdouble = (1. <<= 1); + @Test public void testArithmeticEvaluationWithDoubleShiftAssignOp() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable shiftdouble = helper.assertNonProblem("shiftdouble = ", 11); @@ -14053,12 +14778,14 @@ public void testArithmeticEvaluationWithDoubleShiftAssignOp() throws Exception { // constexpr double zero = 0.; // constexpr double x = 1., y = 1.; // constexpr int shiftpack = ((x > zero) << Horizontal) | ((y > zero) << Vertical); + @Test public void testArithmeticEvaluationOfRelationalOps() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("shiftpack", 3); } // constexpr auto true_value = __builtin_is_constant_evaluated(); + @Test public void testBuiltinIsConstantEvaluated() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("true_value", 1); @@ -14078,6 +14805,7 @@ public void testBuiltinIsConstantEvaluated() throws Exception { // decl_function, // reference site marker // decl_simple, // reference site marker // }; + @Test public void testSimpleDeclarationOfFunction() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -14181,6 +14909,7 @@ public void testSimpleDeclarationOfFunction() throws Exception { // /* 65 */ true == __is_trivially_assignable(E&, E&), // }; // + @Test public void testIsAssignable() throws Exception { //parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU /* use GNU extensions */); BindingAssertionHelper helper = getAssertionHelper(CPP, ScannerKind.GNU /* use GNU extensions */); @@ -14197,6 +14926,6 @@ public void testIsAssignable() throws Exception { } } - assertEquals("Failed evaluations", 0, failures); + assertEquals((long) 0, (long) failures, "Failed evaluations"); } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java index e38f7146bd1..c622b86f85a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CSpecTest.java @@ -16,23 +16,18 @@ import org.eclipse.cdt.core.dom.ast.IASTExpression; import org.eclipse.cdt.core.parser.ParserLanguage; +import org.junit.jupiter.api.Test; /** * @author dsteffle */ public class AST2CSpecTest extends AST2SpecTestBase { - public AST2CSpecTest() { - } - - public AST2CSpecTest(String name) { - super(name); - } - // /* Start Example(C 4-6) */ // #ifdef _ _STDC_IEC_559_ _ // FE_UPWARD defined // fesetround(FE_UPWARD); // #endif + @Test public void test4s6() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -40,6 +35,7 @@ public void test4s6() throws Exception { // /* Start Example(C 5.1.1.3-2) */ // char i; // int i; + @Test public void test5_1_1_3s2() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -49,6 +45,7 @@ public void test5_1_1_3s2() throws Exception { // char c1, c2; // c1 = c1 + c2; // } + @Test public void test5_1_2_3s10() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -59,6 +56,7 @@ public void test5_1_2_3s10() throws Exception { // double d; // f1 = f2 * d; // } + @Test public void test5_1_2_3s11() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -70,6 +68,7 @@ public void test5_1_2_3s11() throws Exception { // d1 = f = 1; // d2 = (float) 1; // } + @Test public void test5_1_2_3s12() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -82,6 +81,7 @@ public void test5_1_2_3s12() throws Exception { // z = x + x * y; // not equivalent toz = x * (1.0 + y); // y = x / 5.0; // not equivalent toy = x * 0.2; // } + @Test public void test5_1_2_3s13() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -95,6 +95,7 @@ public void test5_1_2_3s13() throws Exception { // a = ((a + 32765) + b); // a = (a + (b + 32765)); // } + @Test public void test5_1_2_3s14() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -107,12 +108,14 @@ public void test5_1_2_3s14() throws Exception { // sum = sum * 10 - '0' + (*p++ = getchar()); // sum = (((sum * 10) - '0') + ((*(p++)) = (getchar()))); // } + @Test public void test5_1_2_3s15() throws Exception { parseCandCPP(getAboveComment(), false, 0); } // /* Start Example(C 6.2.5-28) */ // struct tag (* a[5])(float); + @Test public void test6_2_5s28() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -121,6 +124,7 @@ public void test6_2_5s28() throws Exception { // int f(int (*)(), double (*)[3]); // int f(int (*)(char *), double (*)[]); // int f(int (*)(char *), double (*)[3]); + @Test public void test6_2_7s5() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -129,6 +133,7 @@ public void test6_2_7s5() throws Exception { // char x='\023'; // char y='\0'; // char z='\x13'; + @Test public void test6_4_4_4s12() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -142,6 +147,7 @@ public void test6_4_4_4s12() throws Exception { // int foo() { // int x=(*pf[f1()]) (f2(), f3() + f4()); // } + @Test public void test6_5_2_2s12() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -159,6 +165,7 @@ public void test6_5_2_2s12() throws Exception { // vs.i; // volatile int // vs.ci; // volatile const int // } + @Test public void test6_5_2_3s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -185,6 +192,7 @@ public void test6_5_2_3s7() throws Exception { // if (sin(u.nf.doublenode) == 0.0) // return 0; // } + @Test public void test6_5_2_3s8a() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -206,12 +214,14 @@ public void test6_5_2_3s8a() throws Exception { // } u; // return f(&u.s1, &u.s2); // } + @Test public void test6_5_2_3s8b() throws Exception { parseCandCPP(getAboveComment(), false, 0); } // /* Start Example(C 6.5.2.5-9) */ // int *p = (int []){2, 4}; + @Test public void test6_5_2_5s9() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -222,6 +232,7 @@ public void test6_5_2_5s9() throws Exception { // int *p; // p = (int [2]){*p}; // } + @Test public void test6_5_2_5s10() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -233,6 +244,7 @@ public void test6_5_2_5s10() throws Exception { // drawline(&(struct point){.x=1, .y=1}, // &(struct point){.x=3, .y=4}); // } + @Test public void test6_5_2_5s11() throws Exception { parse(getAboveComment(), ParserLanguage.C, false, 0); } @@ -241,6 +253,7 @@ public void test6_5_2_5s11() throws Exception { // int f() { // (const float []){1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6}; // } + @Test public void test6_5_2_5s12() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -251,6 +264,7 @@ public void test6_5_2_5s12() throws Exception { // (char []){"/tmp/fileXXXXXX"}; // (const char []){"/tmp/fileXXXXXX"}; // } + @Test public void test6_5_2_5s13() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -259,6 +273,7 @@ public void test6_5_2_5s13() throws Exception { // int f() { // (const char []){"abc"} == "abc"; // } + @Test public void test6_5_2_5s14() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -269,6 +284,7 @@ public void test6_5_2_5s14() throws Exception { // struct int_list endless_zeros = {0, &endless_zeros}; // eval(endless_zeros); // } + @Test public void test6_5_2_5s15() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -284,6 +300,7 @@ public void test6_5_2_5s15() throws Exception { // if (j < 2) goto again; // return p == q && q->i == 1; // } + @Test public void test6_5_2_5s16() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -291,6 +308,7 @@ public void test6_5_2_5s16() throws Exception { // /* Start Example(C 6.5.3.4-5) */ // extern void *alloc(size_t); // double *dp = alloc(sizeof *dp); + @Test public void test6_5_3_4s5() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -300,6 +318,7 @@ public void test6_5_3_4s5() throws Exception { // int array[5]; // int x = sizeof array / sizeof array[0]; // } + @Test public void test6_5_3_4s6() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -313,6 +332,7 @@ public void test6_5_3_4s6() throws Exception { // (*p)[2] = 99; // a[1][2] == 99 // n = p - a; // n == 1 // } + @Test public void test6_5_6s10() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -333,6 +353,7 @@ public void test6_5_6s10() throws Exception { // cond ? ip : c_ip; // cond ? vp : ip; // } + @Test public void test6_5_15s8() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), ParserLanguage.C); IASTExpression c1 = helper.assertNode("cond ? c_vp : c_ip"); @@ -356,6 +377,7 @@ public void test6_5_15s8() throws Exception { // long l; // l = (c = i); // } + @Test public void test6_5_16_1s5() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -369,6 +391,7 @@ public void test6_5_16_1s5() throws Exception { // *cpp = &c; // valid // *p = 0; // valid // } + @Test public void test6_5_16_1s6() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -383,6 +406,7 @@ public void test6_5_16_1s6() throws Exception { // offsetof(struct s, d); // offsetof(struct ss, d); // } + @Test public void test6_7_2_1s17() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -394,6 +418,7 @@ public void test6_7_2_1s17() throws Exception { // s1 = malloc(sizeof (struct s) + 64); // s2 = malloc(sizeof (struct s) + 46); // } + @Test public void test6_7_2_1s18a() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -401,6 +426,7 @@ public void test6_7_2_1s18a() throws Exception { // /* Start Example(C 6.7.2.1-18b) */ // struct { int n; double d[8]; } *s1; // struct { int n; double d[5]; } *s2; + @Test public void test6_7_2_1s18b() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -414,6 +440,7 @@ public void test6_7_2_1s18b() throws Exception { // if (*cp != burgundy) // return 0; // } + @Test public void test6_7_2_2s5() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -424,6 +451,7 @@ public void test6_7_2_2s5() throws Exception { // struct tnode *left, *right; // }; // struct tnode s, *sp; + @Test public void test6_7_2_3s9() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -435,6 +463,7 @@ public void test6_7_2_3s9() throws Exception { // TNODE *left, *right; // }; // TNODE s, *sp; + @Test public void test6_7_2_3s10() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -443,12 +472,14 @@ public void test6_7_2_3s10() throws Exception { // struct s2; // struct s1 { struct s2 *s2p; }; // D1 // struct s2 { struct s1 *s1p; }; // D2 + @Test public void test6_7_2_3s11() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.7.3-10) */ // extern const volatile int real_time_clock; + @Test public void test6_7_3s10() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -468,6 +499,7 @@ public void test6_7_3s10() throws Exception { // pci = &cs.mem; // valid // pi = a[0]; // invalid: a[0] has type ''const int *'' // } + @Test public void test6_7_3s11() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -476,6 +508,7 @@ public void test6_7_3s11() throws Exception { // int * restrict a; // int * restrict b; // extern int c[]; + @Test public void test6_7_3_1s7() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -486,6 +519,7 @@ public void test6_7_3_1s7() throws Exception { // while (n-- > 0) // *p++ = *q++; // } + @Test public void test6_7_3_1s8() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -502,6 +536,7 @@ public void test6_7_3_1s8() throws Exception { // f(50, d + 50, d); // valid // f(50, d + 1, d); // undefined behavior // } + @Test public void test6_7_3_1s9() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -513,6 +548,7 @@ public void test6_7_3_1s9() throws Exception { // for (i = 0; i < n; i++) // p[i] = q[i] + r[i]; // } + @Test public void test6_7_3_1s10() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -530,6 +566,7 @@ public void test6_7_3_1s10() throws Exception { // p2 = q2; // undefined behavior // } // } + @Test public void test6_7_3_1s11() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -543,6 +580,7 @@ public void test6_7_3_1s11() throws Exception { // t.v = malloc(n * sizeof (float)); // return t; // } + @Test public void test6_7_3_1s12() throws Exception { parse(getAboveComment(), ParserLanguage.C, false, 0); } @@ -561,6 +599,7 @@ public void test6_7_3_1s12() throws Exception { // { // return is_fahr ? cels(temp) : fahr(temp); // } + @Test public void test6_7_4s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -570,12 +609,14 @@ public void test6_7_4s7() throws Exception { // int *const constant_ptr1; // typedef int *int_ptr; // const int_ptr constant_ptr2; + @Test public void test6_7_5_1s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.7.5.2-7) */ // float fa[11], *afp[17]; + @Test public void test6_7_5_2s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -583,6 +624,7 @@ public void test6_7_5_2s7() throws Exception { // /* Start Example(C 6.7.5.2-8) */ // extern int *x; // extern int y[]; + @Test public void test6_7_5_2s8() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -600,6 +642,7 @@ public void test6_7_5_2s8() throws Exception { // r = c; // compatible, but defined behavior only if // // n == 6 andm == n+1 // } + @Test public void test6_7_5_2s9() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -624,24 +667,28 @@ public void test6_7_5_2s9() throws Exception { // extern int (*r)[m]; // invalid: r has linkage and points to VLA // static int (*q)[m] = &B; // valid: q is a static block pointer to VLA // } + @Test public void test6_7_5_2s10() throws Exception { parseCandCPP(getAboveComment(), false, 0); } // /* Start Example(C 6.7.5.3-16) */ // int f(void), *fip(), (*pfi)(); + @Test public void test6_7_5_3s16() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.7.5.3-18) */ // int (*apfi[3])(int *x, int *y); + @Test public void test6_7_5_3s18() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.7.5.3-19) */ // int (*fpfi(int (*)(long), int))(int, ...); + @Test public void test6_7_5_3s19() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -663,6 +710,7 @@ public void test6_7_5_3s19() throws Exception { // // a is a pointer to a VLA with n*m+300 elements // a[i][j] += x; // } + @Test public void test6_7_5_3s20() throws Exception { String code = getAboveComment(); // no valid c++ code @@ -678,6 +726,7 @@ public void test6_7_5_3s20() throws Exception { // void f2(double a[restrict][5]); // void f3(double a[restrict 3][5]); // void f4(double a[restrict static 3][5]); + @Test public void test6_7_5_3s21() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -689,6 +738,7 @@ public void test6_7_5_3s21() throws Exception { // extern KLICKSP *metricp; // range x; // range z, *zp; + @Test public void test6_7_7s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -696,6 +746,7 @@ public void test6_7_7s4() throws Exception { // /* Start Example(C 6.7.7-5) */ // typedef struct s1 { int x; } t1, *tp1; // typedef struct s2 { int x; } t2, *tp2; + @Test public void test6_7_7s5() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -705,6 +756,7 @@ public void test6_7_7s5() throws Exception { // void (*signal(int, void (*)(int)))(int); // fv *signal(int, fv *); // pfv signal(int, pfv); + @Test public void test6_7_7s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -719,6 +771,7 @@ public void test6_7_7s7() throws Exception { // for (int i = 1; i < n; i++) // a[i-1] = b[i]; // } + @Test public void test6_7_7s8() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -726,12 +779,14 @@ public void test6_7_7s8() throws Exception { // /* Start Example(C 6.7.8-24) */ // int i = 3.5; // complex c = 5 + 3 * I; + @Test public void test6_7_8s24() throws Exception { parseCandCPP(getAboveComment(), false, 0); } // /* Start Example(C 6.7.8-25) */ // int x[] = { 1, 3, 5 }; + @Test public void test6_7_8s25() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -742,6 +797,7 @@ public void test6_7_8s25() throws Exception { // { 2, 4, 6 }, // { 3, 5, 7 }, // }; + @Test public void test6_7_8s26a() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -750,6 +806,7 @@ public void test6_7_8s26a() throws Exception { // int y[4][3] = { // 1, 3, 5, 2, 4, 6, 3, 5, 7 // }; + @Test public void test6_7_8s26b() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -758,12 +815,14 @@ public void test6_7_8s26b() throws Exception { // int z[4][3] = { // { 1 }, { 2 }, { 3 }, { 4 } // }; + @Test public void test6_7_8s27() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.7.8-28) */ // struct { int a[3], b; } w[] = { { 1 }, 2 }; + @Test public void test6_7_8s28() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -791,6 +850,7 @@ public void test6_7_8s28() throws Exception { // { 6 }, // } // }; + @Test public void test6_7_8s29() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -799,6 +859,7 @@ public void test6_7_8s29() throws Exception { // typedef int A[]; // OK - declared with block scope // A a1 = { 1, 2 }, b1 = { 3, 4, 5 }; // int a2[] = { 1, 2 }, b2[] = { 3, 4, 5 }; + @Test public void test6_7_8s31() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -810,6 +871,7 @@ public void test6_7_8s31() throws Exception { // t2[] = { 'a', 'b', 'c' }; // char *p = "abc"; // } + @Test public void test6_7_8s32() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -820,12 +882,14 @@ public void test6_7_8s32() throws Exception { // [member_two] = "member two", // [member_one] = "member one", // }; + @Test public void test6_7_8s33() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } // /* Start Example(C 6.7.8-34) */ // div_t answer = { .quot = 2, .rem = -1 }; + @Test public void test6_7_8s34() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 1); // div_t (correctly) cannot be resolved } @@ -833,6 +897,7 @@ public void test6_7_8s34() throws Exception { // /* Start Example(C 6.7.8-35) */ // struct { int a[3], b; } w[] = // { [0].a = {1}, [1].a[0] = 2 }; + @Test public void test6_7_8s35() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -842,12 +907,14 @@ public void test6_7_8s35() throws Exception { // int a[MAX] = { // 1, 3, 5, 7, 9, [MAX-5] = 8, 6, 4, 2, 0 // }; + @Test public void test6_7_8s36() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } // /* Start Example(C 6.7.8-38) */ // union { int any_member; } u = { .any_member = 42 }; + @Test public void test6_7_8s38() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -857,6 +924,7 @@ public void test6_7_8s38() throws Exception { // int f() { // (void)p(0); // } + @Test public void test6_8_3s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -867,6 +935,7 @@ public void test6_8_3s4() throws Exception { // while (*s++ != '\0') // ; // } + @Test public void test6_8_3s5() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -883,6 +952,7 @@ public void test6_8_3s5() throws Exception { // end_loop1: ; // } // } + @Test public void test6_8_3s6() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -900,6 +970,7 @@ public void test6_8_3s6() throws Exception { // f(i+1); // } // } + @Test public void test6_8_4s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -918,6 +989,7 @@ public void test6_8_4s7() throws Exception { // // handle other operations // } // } + @Test public void test6_8_6_1s3() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -937,6 +1009,7 @@ public void test6_8_6_1s3() throws Exception { // } // goto lab4; // invalid: going INTO scope of VLA. // } + @Test public void test6_8_6_1s4() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -960,6 +1033,7 @@ public void test6_8_6_1s4() throws Exception { // int foo() { // g.u2.f3 = f(); // } + @Test public void test6_8_6_4s4() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } @@ -969,6 +1043,7 @@ public void test6_8_6_4s4() throws Exception { // { // return a > b ? a : b; // } + @Test public void test6_9_1s13() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -979,6 +1054,7 @@ public void test6_9_1s13() throws Exception { // (*funcp)(); // funcp(); // } + @Test public void test6_9_1s14() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -999,6 +1075,7 @@ public void test6_9_1s14() throws Exception { // extern int i3; // refers to pre vious, whose linkage is external // extern int i4; // refers to pre vious, whose linkage is external // extern int i5; // refers to pre vious, whose linkage is internal + @Test public void test6_9_2s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1012,6 +1089,7 @@ public void test6_9_2s4() throws Exception { // if ('z' - 'a' == 25) // g(); // } + @Test public void test6_10_1s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1023,6 +1101,7 @@ public void test6_10_1s4() throws Exception { // #define join(c, d) in_between(c hash_hash d) // char p[] = join(x, y); // equivalent to // char p[] = "x ## y"; + @Test public void test6_10_3_3s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1030,12 +1109,14 @@ public void test6_10_3_3s4() throws Exception { // /* Start Example(C 6.10.3.5-3) */ // #define TABSIZE 100 // int table[TABSIZE]; + @Test public void test6_10_3_5s3() throws Exception { parseCandCPP(getAboveComment(), true, 0); } // /* Start Example(C 6.10.3.5-4) */ // #define max(a, b) ((a) > (b) ? (a) : (b)) + @Test public void test6_10_3_5s4() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1059,6 +1140,7 @@ public void test6_10_3_5s4() throws Exception { // p() i[q()] = { q(1), r(2,3), r(4,), r(,5), r(,) }; // char c[2][6] = { str(hello), str() }; // } + @Test public void test6_10_3_5s5() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1083,6 +1165,7 @@ public void test6_10_3_5s5() throws Exception { // char * c = glue(HIGH, LOW); // c = xglue(HIGH, LOW); // } + @Test public void test6_10_3_5s6() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -1091,6 +1174,7 @@ public void test6_10_3_5s6() throws Exception { // #define t(x,y,z) x ## y ## z // int j[] = { t(1,2,3), t(,4,5), t(6,,7), t(8,9,), // t(10,,), t(,11,), t(,,12), t(,,) }; + @Test public void test6_10_3_5s7() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1103,6 +1187,7 @@ public void test6_10_3_5s7() throws Exception { // #define FUNC_LIKE2( a )( \ // a \ // ) + @Test public void test6_10_3_5s8() throws Exception { parseCandCPP(getAboveComment(), true, 0); } @@ -1118,6 +1203,7 @@ public void test6_10_3_5s8() throws Exception { // showlist(The first, second, and third items.); // report(x>y, "x is %d but y is %d", x, y); // } + @Test public void test6_10_3_5s9() throws Exception { parseCandCPP(getAboveComment(), false, 0); } @@ -1132,6 +1218,7 @@ public void test6_10_3_5s9() throws Exception { // }; // t f(t (t)); // long t; + @Test public void test6_7_7s6() throws Exception { parse(getAboveComment(), ParserLanguage.C, true, 0); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java index fa820d64fb0..0c4010e69dd 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2KnRTests.java @@ -15,6 +15,12 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; import org.eclipse.cdt.core.dom.ast.IASTArraySubscriptExpression; import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; @@ -58,19 +64,13 @@ import org.eclipse.cdt.internal.core.dom.parser.c.CScope; import org.eclipse.cdt.internal.core.dom.parser.c.CVisitor; import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding; +import org.junit.jupiter.api.Test; /** * @author dsteffle */ public class AST2KnRTests extends AST2TestBase { - - public AST2KnRTests() { - } - - public AST2KnRTests(String name) { - super(name); - } - + @Test public void testSimpleKRCTest1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(char x);\n"); //$NON-NLS-1$ @@ -113,6 +113,7 @@ public void testSimpleKRCTest1() throws Exception { .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$ } + @Test public void testSimpleKRCTest2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f();\n"); //$NON-NLS-1$ @@ -149,6 +150,7 @@ public void testSimpleKRCTest2() throws Exception { .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$ } + @Test public void testSimpleKRCTest3() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int const *f();\n"); //$NON-NLS-1$ @@ -175,6 +177,7 @@ public void testSimpleKRCTest3() throws Exception { assertEquals(x3, x4); } + @Test public void testKRC_1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$ @@ -228,6 +231,7 @@ public void testKRC_1() throws Exception { .getBinding(CScope.NAMESPACE_TYPE_OTHER, "y".toCharArray())); //$NON-NLS-1$ } + @Test public void testKRCWithTypes() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("typedef char c;\n"); //$NON-NLS-1$ @@ -287,6 +291,7 @@ public void testKRCWithTypes() throws Exception { .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$ } + @Test public void testKRCProblem1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char\n"); //$NON-NLS-1$ @@ -297,6 +302,7 @@ public void testKRCProblem1() throws Exception { assertTrue(CVisitor.getProblems(tu).length > 0); } + @Test public void testKRCProblem2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int i=0;\n"); //$NON-NLS-1$ @@ -308,6 +314,7 @@ public void testKRCProblem2() throws Exception { assertTrue(CVisitor.getProblems(tu).length > 0); } + @Test public void testKRCProblem3() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char y;\n"); //$NON-NLS-1$ @@ -344,6 +351,7 @@ public void testKRCProblem3() throws Exception { assertEquals(decls.length, 0); } + @Test public void testKRCProblem4() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x,y,z) char x,y,z; int a;\n"); //$NON-NLS-1$ @@ -405,6 +413,7 @@ public void testKRCProblem4() throws Exception { assertEquals(decls[0], x2); } + @Test public void testKRCProblem5() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(x) char x,a;\n"); //$NON-NLS-1$ @@ -441,6 +450,7 @@ public void testKRCProblem5() throws Exception { assertEquals(decls.length, 0); } + @Test public void testKRC_monop_cards1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$ @@ -493,8 +503,7 @@ public void testKRC_monop_cards1() throws Exception { assertTrue(A.getDeclSpecifier() instanceof IASTElaboratedTypeSpecifier); IASTName A_struct_name_2 = ((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getName(); assertEquals(A_struct_name_2.toString(), "A_struct"); //$NON-NLS-1$ - assertEquals(((IASTElaboratedTypeSpecifier) A.getDeclSpecifier()).getStorageClass(), - IASTDeclSpecifier.sc_typedef); + assertEquals(A.getDeclSpecifier().getStorageClass(), IASTDeclSpecifier.sc_typedef); ICompositeType A_struct_type2 = (ICompositeType) A_struct_name_2.resolveBinding(); assertEquals(A_struct_type2, A_struct_type1); @@ -577,6 +586,7 @@ public void testKRC_monop_cards1() throws Exception { .getBinding(CScope.NAMESPACE_TYPE_OTHER, "x".toCharArray())); //$NON-NLS-1$ } + @Test public void testKRC_monop_cards2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int\n"); //$NON-NLS-1$ @@ -603,7 +613,7 @@ public void testKRC_monop_cards2() throws Exception { IASTSimpleDeclaration parm_decl = (IASTSimpleDeclaration) ((ICASTKnRFunctionDeclarator) getinp.getDeclarator()) .getParameterDeclarations()[0]; - assertTrue(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).isConst()); + assertTrue(parm_decl.getDeclSpecifier().isConst()); assertEquals(((IASTSimpleDeclSpecifier) parm_decl.getDeclSpecifier()).getType(), IASTSimpleDeclSpecifier.t_char); IASTDeclarator prompt = parm_decl.getDeclarators()[0]; @@ -625,6 +635,7 @@ public void testKRC_monop_cards2() throws Exception { assertEquals(decls[0], prompt2); } + @Test public void testKRC_getParametersOrder() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$ @@ -639,6 +650,7 @@ public void testKRC_getParametersOrder() throws Exception { assertEquals(((CParameter) f_parms[1]).getName(), "b"); //$NON-NLS-1$ } + @Test public void testKRC_Ethereal_1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("struct symbol {\n"); //$NON-NLS-1$ @@ -695,6 +707,7 @@ public void testKRC_Ethereal_1() throws Exception { assertEquals(lemp_name3.resolveBinding(), lemp_name4.resolveBinding()); } + @Test public void testBug97447() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("void f(a) int a; {} \n"); //$NON-NLS-1$ @@ -709,6 +722,7 @@ public void testBug97447() throws Exception { IParameter a = (IParameter) col.getName(4).resolveBinding(); } + @Test public void testBug100104() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("typedef int ush;\n"); //$NON-NLS-1$ @@ -747,6 +761,7 @@ public void testBug100104() throws Exception { // { // return 0; // } + @Test public void testBug203050() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), ParserLanguage.C, ScannerKind.GNU, true); assertTrue(tu.getDeclarations()[0] instanceof IASTSimpleDeclaration); @@ -773,6 +788,7 @@ public void testBug203050() throws Exception { // char (*in_char)(void); // int conv_base; // {} + @Test public void testFunctionPtrParameter_378614() throws Exception { String code = getAboveComment(); parseAndCheckBindings(code, ParserLanguage.C, ScannerKind.GNU); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java index 034a0eee96b..306eb99a4e1 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java @@ -47,11 +47,13 @@ import org.eclipse.cdt.core.parser.ParserLanguage; import org.eclipse.cdt.internal.core.dom.parser.ASTNode; import org.eclipse.core.resources.IFile; +import org.junit.jupiter.api.Test; /** * @author dsteffle */ public class AST2SelectionParseTest extends AST2SelectionParseTestBase { + @Test public void testBaseCase_VariableReference() throws Exception { String code = "void f() { int x; x=3; }"; //$NON-NLS-1$ int offset1 = code.indexOf("x="); //$NON-NLS-1$ @@ -67,9 +69,10 @@ public void testBaseCase_VariableReference() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testBaseCase_FunctionReference() throws Exception { String code = "int x(){x( );}"; //$NON-NLS-1$ int offset1 = code.indexOf("x( "); //$NON-NLS-1$ @@ -81,7 +84,7 @@ public void testBaseCase_FunctionReference() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset1, length).getParent(); assertNotNull(node); assertTrue(node instanceof IASTIdExpression); @@ -89,9 +92,10 @@ public void testBaseCase_FunctionReference() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testBaseCase_FunctionDeclaration() throws Exception { String code = "int x(); x( );"; //$NON-NLS-1$ int offset1 = code.indexOf("x()"); //$NON-NLS-1$ @@ -103,7 +107,7 @@ public void testBaseCase_FunctionDeclaration() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset1, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -111,9 +115,10 @@ public void testBaseCase_FunctionDeclaration() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testBaseCase_FunctionDeclaration2() throws Exception { String code = "int printf( const char *, ... ); "; //$NON-NLS-1$ int offset1 = code.indexOf("printf"); //$NON-NLS-1$ @@ -125,7 +130,7 @@ public void testBaseCase_FunctionDeclaration2() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "printf"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset1, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -133,9 +138,10 @@ public void testBaseCase_FunctionDeclaration2() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "printf"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "printf"); //$NON-NLS-1$ } + @Test public void testBaseCase_VariableDeclaration() throws Exception { String code = "int x = 3;"; //$NON-NLS-1$ int offset1 = code.indexOf("x"); //$NON-NLS-1$ @@ -147,7 +153,7 @@ public void testBaseCase_VariableDeclaration() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset1, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -155,9 +161,10 @@ public void testBaseCase_VariableDeclaration() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testBaseCase_Parameter() throws Exception { String code = "int main( int argc ) { int x = argc; }"; //$NON-NLS-1$ int offset1 = code.indexOf("argc;"); //$NON-NLS-1$ @@ -170,7 +177,7 @@ public void testBaseCase_Parameter() throws Exception { IASTName name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "argc"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset1, length).getParent().getParent(); assertNotNull(node); assertTrue(node instanceof IASTEqualsInitializer); @@ -179,9 +186,10 @@ public void testBaseCase_Parameter() throws Exception { name = ((IASTIdExpression) ((IASTEqualsInitializer) node).getInitializerClause()).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "argc"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "argc"); //$NON-NLS-1$ } + @Test public void testBug57898() throws Exception { Writer writer = new StringWriter(); writer.write("class Gonzo { public: void playHorn(); };\n"); //$NON-NLS-1$ @@ -209,10 +217,11 @@ public void testBug57898() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "playHorn"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "playHorn"); //$NON-NLS-1$ } } + @Test public void testConstructorDestructorDeclaration() throws Exception { Writer writer = new StringWriter(); writer.write("class Gonzo { Gonzo(); ~Gonzo(); };"); //$NON-NLS-1$ @@ -226,7 +235,7 @@ public void testConstructorDestructorDeclaration() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Gonzo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Gonzo"); //$NON-NLS-1$ offset = code.indexOf(" ~Gonzo") + 1; //$NON-NLS-1$ length = "~Gonzo".length(); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, offset, length); @@ -236,10 +245,11 @@ public void testConstructorDestructorDeclaration() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "~Gonzo"); //$NON-NLS-1$ } + @Test public void testBug60264() throws Exception { Writer writer = new StringWriter(); writer.write("namespace Muppets { int i; }\n"); //$NON-NLS-1$ @@ -254,7 +264,7 @@ public void testBug60264() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPNamespace); - assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Muppets"); //$NON-NLS-1$ index = code.indexOf("e Muppets") + 2; //$NON-NLS-1$ length = "Muppets".length(); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -264,10 +274,11 @@ public void testBug60264() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPNamespace); - assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "Muppets"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Muppets"); //$NON-NLS-1$ } + @Test public void testBug61613() throws Exception { Writer writer = new StringWriter(); writer.write("class Foo { // ** (A) **\n"); //$NON-NLS-1$ @@ -288,9 +299,10 @@ public void testBug61613() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPClassType); - assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Foo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Foo"); //$NON-NLS-1$ } + @Test public void testBug60038() throws Exception { Writer writer = new StringWriter(); writer.write("class Gonzo {\n"); //$NON-NLS-1$ @@ -335,7 +347,7 @@ public void testBug60038() throws Exception { name = TestUtil.findImplicitName(name); IBinding binding = name.resolveBinding(); assertTrue(binding instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) binding).getName(), "Gonzo"); //$NON-NLS-1$ + assertEquals(binding.getName(), "Gonzo"); //$NON-NLS-1$ break; default: assertTrue(node instanceof IASTName); @@ -343,13 +355,14 @@ public void testBug60038() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "~Gonzo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "~Gonzo"); //$NON-NLS-1$ break; } } } + @Test public void testMethodReference() throws Exception { Writer writer = new StringWriter(); writer.write("class Sample { public:\n"); //$NON-NLS-1$ @@ -369,9 +382,10 @@ public void testMethodReference() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getAnswer"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "getAnswer"); //$NON-NLS-1$ } + @Test public void testConstructorDefinition() throws Exception { String code = "class ABC { public: ABC(); }; ABC::ABC(){}"; //$NON-NLS-1$ int startIndex = code.indexOf("::ABC") + 2; //$NON-NLS-1$ @@ -383,9 +397,10 @@ public void testConstructorDefinition() throws Exception { assertNotNull(name.resolveBinding()); assertEquals(node.toString(), "ABC"); //$NON-NLS-1$ assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "ABC"); //$NON-NLS-1$ } + @Test public void testBug63966() throws Exception { Writer writer = new StringWriter(); writer.write("void foo(int a) {}\n"); //$NON-NLS-1$ @@ -402,7 +417,7 @@ public void testBug63966() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "foo"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent(); assertNotNull(node); assertTrue(node instanceof IASTIdExpression); @@ -410,9 +425,10 @@ public void testBug63966() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "foo"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "foo"); //$NON-NLS-1$ } + @Test public void testBug66744() throws Exception { Writer writerCPP = new StringWriter(); writerCPP.write("enum EColours { RED, GREEN, BLUE }; \n"); //$NON-NLS-1$ @@ -433,7 +449,7 @@ public void testBug66744() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IEnumeration); - assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "EColours"); //$NON-NLS-1$ startIndex = codeCPP.indexOf("EColours color"); //$NON-NLS-1$ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent(); assertNotNull(node); @@ -442,9 +458,10 @@ public void testBug66744() throws Exception { name = ((IASTNamedTypeSpecifier) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IEnumeration); - assertEquals(((IEnumeration) name.resolveBinding()).getName(), "EColours"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "EColours"); //$NON-NLS-1$ } + @Test public void testBug68527() throws Exception { Writer writer = new StringWriter(); writer.write("struct X;\n"); //$NON-NLS-1$ @@ -459,7 +476,7 @@ public void testBug68527() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "X"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, startIndex, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -467,9 +484,10 @@ public void testBug68527() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "X"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "X"); //$NON-NLS-1$ } + @Test public void testBug60407() throws Exception { Writer writer = new StringWriter(); writer.write("struct ZZZ { int x, y, z; };\n"); //$NON-NLS-1$ @@ -491,7 +509,7 @@ public void testBug60407() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "static_function"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent(); assertNotNull(node); assertTrue(node instanceof IASTIdExpression); @@ -499,9 +517,10 @@ public void testBug60407() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "static_function"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "static_function"); //$NON-NLS-1$ } + @Test public void testBug61800() throws Exception { Writer writer = new StringWriter(); writer.write("class B {};\n"); //$NON-NLS-1$ @@ -518,9 +537,10 @@ public void testBug61800() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "stInt"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "stInt"); //$NON-NLS-1$ } + @Test public void testBug68739() throws Exception { Writer writer = new StringWriter(); writer.write("int fprintf( int *, const char *, ... ); \n"); //$NON-NLS-1$ @@ -539,7 +559,7 @@ public void testBug68739() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "fprintf"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, startIndex, length).getParent(); assertNotNull(node); assertTrue(node instanceof IASTIdExpression); @@ -547,9 +567,10 @@ public void testBug68739() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "fprintf"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "fprintf"); //$NON-NLS-1$ } + @Test public void testBug72818() throws Exception { Writer writerCPP = new StringWriter(); writerCPP.write("union Squaw { int x; double u; };\n"); //$NON-NLS-1$ @@ -574,7 +595,7 @@ public void testBug72818() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Squaw"); //$NON-NLS-1$ startIndex = codeCPP.indexOf("sizeof( ") + "sizeof( ".length(); //$NON-NLS-1$ //$NON-NLS-2$ node = parse(codeCPP, ParserLanguage.CPP, startIndex, length).getParent().getParent(); assertNotNull(node); @@ -583,9 +604,10 @@ public void testBug72818() throws Exception { name = ((IASTNamedTypeSpecifier) ((IASTTypeId) node).getDeclSpecifier()).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPClassType); - assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Squaw"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Squaw"); //$NON-NLS-1$ } + @Test public void test72220() throws Exception { Writer writer = new StringWriter(); writer.write("const int FOUND_ME = 1;\n"); //$NON-NLS-1$ @@ -606,9 +628,10 @@ public void test72220() throws Exception { IASTName name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "FOUND_ME"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "FOUND_ME"); //$NON-NLS-1$ } + @Test public void testBug72721() throws Exception { Writer writer = new StringWriter(); writer.write(" class ABC { public: ABC(int); }; \n"); //$NON-NLS-1$ @@ -627,9 +650,10 @@ public void testBug72721() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "ABC"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "ABC"); //$NON-NLS-1$ } + @Test public void testBug72372() throws Exception { Writer writer = new StringWriter(); writer.write("namespace B { \n"); //$NON-NLS-1$ @@ -648,9 +672,10 @@ public void testBug72372() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "f_SD"); //$NON-NLS-1$ } + @Test public void testBug72372_2() throws Exception { Writer writer = new StringWriter(); writer.write("namespace A { \n"); //$NON-NLS-1$ @@ -673,9 +698,10 @@ public void testBug72372_2() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "f_SD"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "f_SD"); //$NON-NLS-1$ } + @Test public void testBug72713() throws Exception { Writer writer = new StringWriter(); writer.write("class Deck{ void initialize(); }; \n"); //$NON-NLS-1$ @@ -691,9 +717,10 @@ public void testBug72713() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "initialize"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "initialize"); //$NON-NLS-1$ } + @Test public void testBug72712() throws Exception { Writer writer = new StringWriter(); writer.write("class B{ public: B(); }; void f(){ B* b; b = new B(); }"); //$NON-NLS-1$ @@ -709,9 +736,10 @@ public void testBug72712() throws Exception { name = TestUtil.findImplicitName(name); IBinding binding = name.resolveBinding(); assertTrue(binding instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) binding).getName(), "B"); //$NON-NLS-1$ + assertEquals(binding.getName(), "B"); //$NON-NLS-1$ } + @Test public void testBug72712_2() throws Exception { Writer writer = new StringWriter(); writer.write("class A {}; \n"); //$NON-NLS-1$ @@ -728,9 +756,10 @@ public void testBug72712_2() throws Exception { IASTName name = ((IASTNamedTypeSpecifier) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPClassType); - assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "A"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "A"); //$NON-NLS-1$ } + @Test public void testBug72710() throws Exception { Writer writer = new StringWriter(); writer.write("class Card{\n"); //$NON-NLS-1$ @@ -750,9 +779,10 @@ public void testBug72710() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ } + @Test public void testBug75731() throws Exception { Writer writer = new StringWriter(); writer.write("int rank() {\n"); //$NON-NLS-1$ @@ -780,7 +810,7 @@ public void testBug75731() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("class Card{") + 6; //$NON-NLS-1$ length = "Card".length(); //$NON-NLS-1$ @@ -791,7 +821,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPClassType); - assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Card"); //$NON-NLS-1$ index = code.indexOf("Card( int rank );"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -801,7 +831,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Card"); //$NON-NLS-1$ index = code.indexOf("Card( int rank );") + 10; //$NON-NLS-1$ length = "rank".length(); //$NON-NLS-1$ @@ -812,7 +842,7 @@ public void testBug75731() throws Exception { name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("int rank;") + 4; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length).getParent(); @@ -822,7 +852,7 @@ public void testBug75731() throws Exception { name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("int getRank();") + 4; //$NON-NLS-1$ length = "getRank".length(); //$NON-NLS-1$ @@ -833,7 +863,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "getRank"); //$NON-NLS-1$ index = code.indexOf("Card::Card( int rank )"); //$NON-NLS-1$ length = "Card".length(); //$NON-NLS-1$ @@ -844,7 +874,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPClassType); - assertEquals(((ICPPClassType) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Card"); //$NON-NLS-1$ index = code.indexOf("Card::Card( int rank )") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -854,7 +884,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPConstructor); - assertEquals(((ICPPConstructor) name.resolveBinding()).getName(), "Card"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Card"); //$NON-NLS-1$ index = code.indexOf("Card::Card( int rank )") + 16; //$NON-NLS-1$ length = "rank".length(); //$NON-NLS-1$ @@ -865,7 +895,7 @@ public void testBug75731() throws Exception { name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = ::rank();") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -875,7 +905,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = ::rank();") + 15; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -885,7 +915,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IFunction); - assertEquals(((IFunction) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = this->rank;") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -895,7 +925,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = this->rank;") + 19; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -905,7 +935,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = rank;") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -915,7 +945,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = rank;") + 13; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length).getParent(); @@ -925,7 +955,7 @@ public void testBug75731() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = Card::rank;") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -935,7 +965,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = Card::rank;") + 19; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -945,7 +975,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = getRank();") + 6; //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); @@ -955,7 +985,7 @@ public void testBug75731() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPField); - assertEquals(((ICPPField) name.resolveBinding()).getName(), "rank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "rank"); //$NON-NLS-1$ index = code.indexOf("this->rank = getRank();") + 13; //$NON-NLS-1$ length = "getRank".length(); //$NON-NLS-1$ @@ -966,9 +996,10 @@ public void testBug75731() throws Exception { name = ((IASTIdExpression) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPMethod); - assertEquals(((ICPPMethod) name.resolveBinding()).getName(), "getRank"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "getRank"); //$NON-NLS-1$ } + @Test public void testBug77989() throws Exception { Writer writer = new StringWriter(); writer.write("namespace N { /* A */\n"); //$NON-NLS-1$ @@ -986,9 +1017,10 @@ public void testBug77989() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICPPNamespace); - assertEquals(((ICPPNamespace) name.resolveBinding()).getName(), "N"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "N"); //$NON-NLS-1$ } + @Test public void testBug78435() throws Exception { Writer writer = new StringWriter(); writer.write("int itself; //A\n"); //$NON-NLS-1$ @@ -1004,7 +1036,7 @@ public void testBug78435() throws Exception { IASTName name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "itself"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length).getParent(); assertNotNull(node); assertTrue(node instanceof IASTDeclarator); @@ -1012,9 +1044,10 @@ public void testBug78435() throws Exception { name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IVariable); - assertEquals(((IVariable) name.resolveBinding()).getName(), "itself"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "itself"); //$NON-NLS-1$ } + @Test public void testBug78231A() throws Exception { Writer writer = new StringWriter(); writer.write("struct Base {\n"); //$NON-NLS-1$ @@ -1031,7 +1064,7 @@ public void testBug78231A() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Data"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -1039,9 +1072,10 @@ public void testBug78231A() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Data"); //$NON-NLS-1$ } + @Test public void testBug78231B() throws Exception { Writer writer = new StringWriter(); writer.write("int Data;\n"); //$NON-NLS-1$ @@ -1059,7 +1093,7 @@ public void testBug78231B() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Data"); //$NON-NLS-1$ node = parse(code, ParserLanguage.CPP, index, length); assertNotNull(node); assertTrue(node instanceof IASTName); @@ -1067,9 +1101,10 @@ public void testBug78231B() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ICompositeType); - assertEquals(((ICompositeType) name.resolveBinding()).getName(), "Data"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "Data"); //$NON-NLS-1$ } + @Test public void testSimpleKRCTest1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(char x);\n"); //$NON-NLS-1$ @@ -1086,9 +1121,10 @@ public void testSimpleKRCTest1() throws Exception { IASTName name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testSimpleKRCTest2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f();\n"); //$NON-NLS-1$ @@ -1105,9 +1141,10 @@ public void testSimpleKRCTest2() throws Exception { IASTName name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testSimpleKRCTest3() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int const *f();\n"); //$NON-NLS-1$ @@ -1124,9 +1161,10 @@ public void testSimpleKRCTest3() throws Exception { IASTName name = ((IASTSimpleDeclaration) node).getDeclarators()[0].getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testKRC_1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int isroot (x, y) /* comment */ \n"); //$NON-NLS-1$ @@ -1144,9 +1182,10 @@ public void testKRC_1() throws Exception { IASTName name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "y"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "y"); //$NON-NLS-1$ } + @Test public void testKRCWithTypes() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("typedef char c;\n"); //$NON-NLS-1$ @@ -1165,7 +1204,7 @@ public void testKRCWithTypes() throws Exception { IASTName name = ((IASTNamedTypeSpecifier) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof ITypedef); - assertEquals(((ITypedef) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "c"); //$NON-NLS-1$ index = code.indexOf("x;"); //$NON-NLS-1$ length = "x".length(); //$NON-NLS-1$ @@ -1176,9 +1215,10 @@ public void testKRCWithTypes() throws Exception { name = ((IASTDeclarator) node).getName(); assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "x"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "x"); //$NON-NLS-1$ } + @Test public void testKRC_monop_cards1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#ifdef __STDC__\n"); //$NON-NLS-1$ @@ -1214,7 +1254,7 @@ public void testKRC_monop_cards1() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IField); - assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "c"); //$NON-NLS-1$ index = code.indexOf("c[2]"); //$NON-NLS-1$ length = "c".length(); //$NON-NLS-1$ @@ -1224,9 +1264,10 @@ public void testKRC_monop_cards1() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IField); - assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "c"); //$NON-NLS-1$ } + @Test public void testKRC_monop_cards2() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int\n"); //$NON-NLS-1$ @@ -1244,7 +1285,7 @@ public void testKRC_monop_cards2() throws Exception { assertEquals(name.toString(), "list"); //$NON-NLS-1$ assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "list"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "list"); //$NON-NLS-1$ index = code.indexOf("[]"); //$NON-NLS-1$ length = "[]".length(); //$NON-NLS-1$ @@ -1259,6 +1300,7 @@ public void testKRC_monop_cards2() throws Exception { assertTrue(node instanceof IASTPointer); } + @Test public void testKRC_getParametersOrder() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int f(a, b) int b,a;{}\n"); //$NON-NLS-1$ @@ -1273,9 +1315,10 @@ public void testKRC_getParametersOrder() throws Exception { assertEquals(name.toString(), "b"); //$NON-NLS-1$ assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IParameter); - assertEquals(((IParameter) name.resolveBinding()).getName(), "b"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "b"); //$NON-NLS-1$ } + @Test public void testKRC_Ethereal_1() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("struct symbol {\n"); //$NON-NLS-1$ @@ -1309,7 +1352,7 @@ public void testKRC_Ethereal_1() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IField); - assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "symbols"); //$NON-NLS-1$ index = code.indexOf("lemp->symbols") + 6; //$NON-NLS-1$ length = "symbols".length(); //$NON-NLS-1$ @@ -1319,9 +1362,10 @@ public void testKRC_Ethereal_1() throws Exception { name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IField); - assertEquals(((IField) name.resolveBinding()).getName(), "symbols"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "symbols"); //$NON-NLS-1$ } + @Test public void testBug86698() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("struct C;\n"); //$NON-NLS-1$ @@ -1340,10 +1384,11 @@ public void testBug86698() throws Exception { IASTName name = (IASTName) node; assertNotNull(name.resolveBinding()); assertTrue(name.resolveBinding() instanceof IField); - assertEquals(((IField) name.resolveBinding()).getName(), "c"); //$NON-NLS-1$ + assertEquals(name.resolveBinding().getName(), "c"); //$NON-NLS-1$ } + @Test public void testLittleThings() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("int a[3];\r\n"); //$NON-NLS-1$ @@ -1414,6 +1459,7 @@ public void testLittleThings() throws Exception { } } + @Test public void testSimpleWindowsPreprocessorSelections() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$ @@ -1460,6 +1506,7 @@ public void testSimpleWindowsPreprocessorSelections() throws Exception { } } + @Test public void testBug86993() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#define _BEGIN_STD_C extern \"C\" {\r\n"); //$NON-NLS-1$ @@ -1485,6 +1532,7 @@ public void testBug86993() throws Exception { assertTrue(name.resolveBinding() instanceof IVariable); } + @Test public void testBug86870() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#if VERSION == 1\r\n"); //$NON-NLS-1$ @@ -1533,6 +1581,7 @@ public void testBug86870() throws Exception { assertEquals(((ASTNode) node).getLength(), length); } + @Test public void testBug87179() throws Exception { StringBuilder buffer = new StringBuilder(); buffer.append("#define ONE 1\r\n"); //$NON-NLS-1$ @@ -1549,6 +1598,7 @@ public void testBug87179() throws Exception { assertNotNull(node); } + @Test public void testBug96702() throws Exception { importFile("test.h", "int x;\n"); //$NON-NLS-1$ //$NON-NLS-2$ String code = "#include \"test.h\" // comment \nvoid f(); // comment \n"; //$NON-NLS-1$ @@ -1561,6 +1611,7 @@ public void testBug96702() throws Exception { assertEquals(((ASTNode) node).getLength(), 1); } + @Test public void testBug97301() throws Exception { StringBuilder buffer = new StringBuilder(); // test2.h: @@ -1601,6 +1652,7 @@ public void testBug97301() throws Exception { assertEquals(fileOffset, fileLocOffset); } + @Test public void testBug86126() throws Exception { String header = "foo" + System.currentTimeMillis() + ".h"; String source = "blah" + System.currentTimeMillis() + ".c"; @@ -1613,6 +1665,7 @@ public void testBug86126() throws Exception { assertNotNull(node); } + @Test public void testBug98806() throws Exception { String code = "template class A { typedef typename T::B _B;};"; IASTNode node = parse(code, ParserLanguage.CPP, code.indexOf("T::B"), "T::B".length()); diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java index 2115fe0e6cd..88aa68eab0e 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SpecTestBase.java @@ -14,6 +14,8 @@ *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.ast2; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.List; @@ -45,14 +47,6 @@ * @author dsteffle */ public abstract class AST2SpecTestBase extends AST2TestBase { - public AST2SpecTestBase() { - super(); - } - - public AST2SpecTestBase(String name) { - super(name); - } - /** * checkSemantics is used to specify whether the example should have semantics checked * since several spec examples have syntactically correct code ONLY this flag was added diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java index 02764bb0445..b1e697f4109 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateLValueRValueTests.java @@ -1,6 +1,7 @@ package org.eclipse.cdt.core.parser.tests.ast2; import static org.eclipse.cdt.core.parser.ParserLanguage.CPP; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.IOException; @@ -9,16 +10,10 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionInstance; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunctionTemplate; import org.eclipse.cdt.internal.core.parser.ParserException; +import org.junit.jupiter.api.Test; public class AST2TemplateLValueRValueTests extends AST2CPPTestBase { - public AST2TemplateLValueRValueTests() { - } - - public AST2TemplateLValueRValueTests(String name) { - super(name); - } - // class clazz { // }; // @@ -46,6 +41,7 @@ public AST2TemplateLValueRValueTests(String name) { // { // demo(getClazz()); // } + @Test public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_function() throws Exception { parseAndCheckBindings(); BindingAssertionHelper helper = getAssertionHelper(); @@ -86,6 +82,7 @@ public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_function() t // { // demo(getClazz()); // } + @Test public void test_lvalueTypedef_rvalueTypedef_caller_templateLvalue_templateRvalue_function() throws Exception { parseAndCheckBindings(); @@ -128,6 +125,7 @@ public void test_lvalueTypedef_rvalueTypedef_caller_templateLvalue_templateRvalu // { // demo(getClazz()); // } + @Test public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateLvalue_templateRvalue_function() throws Exception { parseAndCheckBindings(); @@ -170,6 +168,7 @@ public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateLvalue_templat // { // demo(getClazz()); // } + @Test public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateTpedefLvalue_templateRvalue_function() throws Exception { parseAndCheckBindings(); @@ -204,6 +203,7 @@ public void test_lvalueTypedefRef_rvalueTypedefRef_caller_templateTpedefLvalue_t // int c; // demo(c); // } + @Test public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_lvalue_function() throws Exception { parseAndCheckBindings(); @@ -225,6 +225,7 @@ public void test_lvalue_rvalue_caller_templateLvalue_templateRvalue_lvalue_funct // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_rvalue_function() throws Exception { parseAndCheckBindingsForOneProblem(); } @@ -241,6 +242,7 @@ public void test_lvalue_caller_rvalue_function() throws Exception { // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -267,6 +269,7 @@ public void test_lvalue_caller_lvalue_function() throws Exception { // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_lvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -287,6 +290,7 @@ public void test_rvalue_caller_lvalue_rvalue_function() throws Exception { // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_templateRvalue_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -312,6 +316,7 @@ public void test_lvalue_caller_templateRvalue_lvalue_function() throws Exception // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templateRvalue_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -332,6 +337,7 @@ public void test_rvalue_caller_templateRvalue_lvalue_function() throws Exception // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_lvalue_function() throws Exception { parseAndCheckBindingsForOneProblem(); } @@ -352,6 +358,7 @@ public void test_rvalue_caller_lvalue_function() throws Exception { // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -372,6 +379,7 @@ public void test_rvalue_caller_rvalue_function() throws Exception { // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templateLvalue_function() throws Exception { parseAndCheckBindingsForOneProblem(); } @@ -393,6 +401,7 @@ public void test_rvalue_caller_templateLvalue_function() throws Exception { // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templateRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -414,6 +423,7 @@ public void test_rvalue_caller_templateRvalue_function() throws Exception { // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller__templateRvalue_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -433,6 +443,7 @@ public void test_templatedRvalue_caller__templateRvalue_lvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller__templateRvalue_lvalue_function() throws Exception { parseAndCheckBindingsForProblem(); } @@ -452,6 +463,7 @@ public void test_templatedLvalue_caller__templateRvalue_lvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_templateLvalue_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -476,6 +488,7 @@ public void test_lvalue_caller_templateLvalue_lvalue_function() throws Exception // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templateLvalue_lvalue_function() throws Exception { parseAndCheckBindingsForOneProblem(); } @@ -500,6 +513,7 @@ public void test_rvalue_caller_templateLvalue_lvalue_function() throws Exception // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedLValue_lvalAST2TemplateRValueRValueTestsue_function() throws Exception { parseAndCheckBindingsForProblem(); @@ -520,6 +534,7 @@ public void test_templatedRvalue_caller_templatedLValue_lvalAST2TemplateRValueRV // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedLValue_lvalue_function() throws Exception { parseAndCheckBindings(); } @@ -539,6 +554,7 @@ public void test_templatedLvalue_caller_templatedLValue_lvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_templatedRvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -563,6 +579,7 @@ public void test_lvalue_caller_templatedRvalue_rvalue_function() throws Exceptio // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templatedRvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -587,6 +604,7 @@ public void test_rvalue_caller_templatedRvalue_rvalue_function() throws Exceptio // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedRvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -606,6 +624,7 @@ public void test_templatedRvalue_caller_templatedRvalue_rvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedRvalue_rvalue_function() throws Exception { parseAndCheckBindingsForProblem(); } @@ -625,6 +644,7 @@ public void test_templatedLvalue_caller_templatedRvalue_rvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_templatedLvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -649,6 +669,7 @@ public void test_lvalue_caller_templatedLvalue_rvalue_function() throws Exceptio // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templatedLvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -673,6 +694,7 @@ public void test_rvalue_caller_templatedLvalue_rvalue_function() throws Exceptio // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedLvalue_rvalue_function() throws Exception { parseAndCheckBindingsForProblem(); } @@ -692,6 +714,7 @@ public void test_templatedRvalue_caller_templatedLvalue_rvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedLvalue_rvalue_function() throws Exception { parseAndCheckBindings(); } @@ -712,6 +735,7 @@ public void test_templatedLvalue_caller_templatedLvalue_rvalue_function() throws // clazz c; // demo(c); // } + @Test public void test_lvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -737,6 +761,7 @@ public void test_lvalue_caller_templatedLvalue_templatedRvalue_function() throws // { // demo(getClazz()); // } + @Test public void test_rvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -762,6 +787,7 @@ public void test_rvalue_caller_templatedLvalue_templatedRvalue_function() throws // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -782,6 +808,7 @@ public void test_templatedRvalue_caller_templatedLvalue_templatedRvalue_function // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedLvalue_templatedRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -803,6 +830,7 @@ public void test_templatedLvalue_caller_templatedLvalue_templatedRvalue_function // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedLvalue_function() throws Exception { parseAndCheckBindingsForProblem(); } @@ -824,6 +852,7 @@ public void test_templatedRvalue_caller_templatedLvalue_function() throws Except // { // demo(getClazz()); // } + @Test public void test_templatedRvalue_caller_templatedRvalue_function() throws Exception { parseAndCheckBindings(); } @@ -840,6 +869,7 @@ public void test_templatedRvalue_caller_templatedRvalue_function() throws Except // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedLvalue_function() throws Exception { parseAndCheckBindings(); } @@ -856,6 +886,7 @@ public void test_templatedLvalue_caller_templatedLvalue_function() throws Except // clazz c; // demo(c); // } + @Test public void test_templatedLvalue_caller_templatedRvalue_function() throws Exception { parseAndCheckBindingsForProblem(); } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index bf88377f26b..7e1b7266307 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -27,6 +27,13 @@ import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.TDEF; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getNestedType; import static org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil.getUltimateType; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; @@ -49,7 +56,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IFunction; @@ -110,28 +116,17 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; - -import junit.framework.TestSuite; +import org.junit.jupiter.api.Test; public class AST2TemplateTests extends AST2CPPTestBase { - public AST2TemplateTests() { - } - - public AST2TemplateTests(String name) { - super(name); - } - - public static TestSuite suite() { - return suite(AST2TemplateTests.class); - } - private NameCollector getNameCollector(IASTTranslationUnit ast) { NameCollector collector = new NameCollector(); ast.accept(collector); return collector; } + @Test public void testBasicClassTemplate() throws Exception { IASTTranslationUnit tu = parse("template class A{ T t; };", CPP); //$NON-NLS-1$ NameCollector col = new NameCollector(); @@ -164,6 +159,7 @@ public void testBasicClassTemplate() throws Exception { // A a; // a.t1; a.t2; // } + @Test public void testBasicTemplateInstance_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -188,7 +184,7 @@ public void testBasicTemplateInstance_a() throws Exception { assertSame(((ICPPTemplateInstance) A_int).getTemplateDefinition(), A); ICPPClassScope A_int_Scope = (ICPPClassScope) A_int.getCompositeScope(); - assertNotSame(A_int_Scope, ((ICompositeType) A).getCompositeScope()); + assertNotSame(A_int_Scope, A.getCompositeScope()); ICPPField t = (ICPPField) col.getName(11).resolveBinding(); assertTrue(t instanceof ICPPSpecialization); @@ -215,6 +211,7 @@ public void testBasicTemplateInstance_a() throws Exception { // A a; // a.f((int*)0); // } + @Test public void testBasicTemplateInstance_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -247,6 +244,7 @@ public void testBasicTemplateInstance_b() throws Exception { // void foo() { // f(0); // } + @Test public void testBasicTemplateFunction() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -276,6 +274,7 @@ public void testBasicTemplateFunction() throws Exception { // template < class T > class pair { // template < class U > pair(const pair &); // }; + @Test public void testStackOverflow_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -297,6 +296,7 @@ public void testStackOverflow_a() throws Exception { // template < class T > class A {}; // template < class T > class A< T* > {}; // template < class T > class A< T** > {}; + @Test public void testBasicClassPartialSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -325,6 +325,7 @@ public void testBasicClassPartialSpecialization() throws Exception { // template < class T > class A { typedef int TYPE; }; // template < class T > typename A::TYPE foo(T); // template < class T > typename A::TYPE foo(T); + @Test public void testStackOverflow_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -360,6 +361,7 @@ public void testStackOverflow_b() throws Exception { // struct A : public _A_::member_t {}; // // struct B : public A{}; + @Test public void testStackOverflowInBaseComputation_418996() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPClassType B = helper.assertNonProblem("A", 4); @@ -371,6 +373,7 @@ public void testStackOverflowInBaseComputation_418996() throws Exception { // void f(); // }; // template < class T > void A::f() { } + @Test public void testTemplateMemberDef() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -389,6 +392,7 @@ public void testTemplateMemberDef() throws Exception { // const int *p; // f(p); //calls f(const T *) , 3 is more specialized than 1 or 2 // } + @Test public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -413,6 +417,7 @@ public void test14_5_5_2s5_OrderingFunctionTemplates_a() throws Exception { // float x; // f(x); //ambiguous 1 or 2 // } + @Test public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -431,6 +436,7 @@ public void test14_5_5_2s5_OrderingFunctionTemplates_b() throws Exception { // void main() { // f({1,2,3}); // } + @Test public void test_dr1591_DeduceArrayFromInitializerList_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -450,6 +456,7 @@ public void test_dr1591_DeduceArrayFromInitializerList_a() throws Exception { // void main() { // f({1,2,3}); // } + @Test public void test_dr1591_DeduceArrayFromInitializerList_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -469,6 +476,7 @@ public void test_dr1591_DeduceArrayFromInitializerList_b() throws Exception { // void main() { // f({1,2.0,3}); // } + @Test public void test_dr1591_DeduceArrayFromInitializerList_c() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -486,6 +494,7 @@ public void test_dr1591_DeduceArrayFromInitializerList_c() throws Exception { // template < class T, template < class X > class U, T *pT > class A { // }; + @Test public void testTemplateParameters() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -513,6 +522,7 @@ public void testTemplateParameters() throws Exception { // A * b; // b->a; // } + @Test public void testDeferredInstances() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -553,6 +563,7 @@ public void testDeferredInstances() throws Exception { // A a3; //uses #4, T is char // A a4; //uses #5, T is int, T2 is char, I is1 // A a5; //ambiguous, matches #3 & #5. + @Test public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -596,6 +607,7 @@ public void test14_5_4_1s2_MatchingTemplateSpecializations() throws Exception { // template class A { }; // template class A ()> { }; // A a1; // uses specialisation + @Test public void testPrimitiveMatchingSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -616,6 +628,7 @@ public void testPrimitiveMatchingSpecializations() throws Exception { // template void f(T*); // template <> void f(int); //ok // template <> void f(int*); //ok + @Test public void test14_7_3_FunctionExplicitSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -633,6 +646,7 @@ public void test14_7_3_FunctionExplicitSpecialization() throws Exception { // template void f(T*); // void g(int* p) { f(p); } + @Test public void test14_5_5_1_FunctionTemplates_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -647,6 +661,7 @@ public void test14_5_5_1_FunctionTemplates_a() throws Exception { // template void f(T); // void g(int* p) { f(p); } + @Test public void test14_5_5_1_FunctionTemplates_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -663,6 +678,7 @@ public void test14_5_5_1_FunctionTemplates_b() throws Exception { // void g(){ // int i = f(5); // Y is int // } + @Test public void test14_8_1s2_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -679,6 +695,7 @@ public void test14_8_1s2_FunctionTemplates() throws Exception { // void g(){ // f("Annemarie"); // } + @Test public void test14_8_3s6_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -699,6 +716,7 @@ public void test14_8_3s6_FunctionTemplates() throws Exception { // f(ip); //calls #2 // g(ip); //calls #4 // } + @Test public void test14_5_5_2s6_FunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -726,6 +744,7 @@ public void test14_5_5_2s6_FunctionTemplates() throws Exception { // X* p; // meaning X // X* p2; // }; + @Test public void test14_6_1s1_LocalNames() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -747,6 +766,7 @@ public void test14_6_1s1_LocalNames() throws Exception { // f(&a); //call f(int*) // f(&b); //call f(char**) // } + @Test public void test14_8s2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -778,6 +798,7 @@ public void test14_8s2() throws Exception { // template inline T g(T) { } // template<> inline void f<>(int) { } //OK: inline // template<> int g<>(int) { } // OK: not inline + @Test public void test14_7_3s14() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -792,8 +813,8 @@ public void test14_7_3s14() throws Exception { assertSame(f2.getSpecializedBinding(), f1); assertSame(g2.getSpecializedBinding(), g1); - assertFalse(((ICPPFunction) f1).isInline()); - assertTrue(((ICPPFunction) g1).isInline()); + assertFalse(f1.isInline()); + assertTrue(g1.isInline()); assertTrue(((ICPPFunction) f2).isInline()); assertFalse(((ICPPFunction) g2).isInline()); } @@ -807,6 +828,7 @@ public void test14_7_3s14() throws Exception { // X x; // x.a.a.a.a; // } + @Test public void test14_7_1s14_InfiniteInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -839,6 +861,7 @@ public void test14_7_1s14_InfiniteInstantiation() throws Exception { // Y* p; // meaning Y // Y* q; // meaning Y // }; + @Test public void test14_6_1s2() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -863,6 +886,7 @@ public void test14_6_1s2() throws Exception { // void foo () { // f(g); // } + @Test public void testBug45129() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -886,6 +910,7 @@ public void testBug45129() throws Exception { // A a; // a.u; // } + @Test public void testBug76951() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -916,6 +941,7 @@ public void testBug76951() throws Exception { // A< int > a; // }; // void f(A p) { } + @Test public void testInstances() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -932,6 +958,7 @@ public void testInstances() throws Exception { // template void f(T); // template void f(T) {} + @Test public void testTemplateParameterDeclarations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -954,6 +981,7 @@ public void testTemplateParameterDeclarations() throws Exception { // a->f(a); // a->pA; // }; + @Test public void testDeferredInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1000,6 +1028,7 @@ public void testDeferredInstantiation() throws Exception { // ac.f('c'); //template // ac.f<>(1); //template // } + @Test public void test14_5_2s2_MemberSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1044,6 +1073,7 @@ public void test14_5_2s2_MemberSpecializations() throws Exception { // template <> class A {}; // A ac; // A ai; + @Test public void testClassSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1076,6 +1106,7 @@ public void testClassSpecializations() throws Exception { // // explicit specialization syntax not used for a member of // // explicitly specialized class template specialization // void A::f(int) { } + @Test public void test14_7_3s5_SpecializationMemberDefinition() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1113,6 +1144,7 @@ public void test14_7_3s5_SpecializationMemberDefinition() throws Exception { // C c; // b.f(c); // } + @Test public void testNestedSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1155,6 +1187,7 @@ public void testNestedSpecializations() throws Exception { // template class A { }; // } // A a; + @Test public void test14_5_4s7_UsingClassTemplate() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1186,6 +1219,7 @@ public void test14_5_4s7_UsingClassTemplate() throws Exception { // C c; // c.y.x; c.z.x; // } + @Test public void testTemplateTemplateParameter() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1234,6 +1268,7 @@ public void testTemplateTemplateParameter() throws Exception { // A a; // a.t; // } + @Test public void testNestedTypeSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1268,6 +1303,7 @@ public void testNestedTypeSpecializations() throws Exception { // A a; // a.b.t; // } + @Test public void testNestedClassTypeSpecializations() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1307,6 +1343,7 @@ public void testNestedClassTypeSpecializations() throws Exception { // void f() { // A< C > a; a.s; // }; + @Test public void testTemplateParameterQualifiedType() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1359,6 +1396,7 @@ public void testTemplateParameterQualifiedType() throws Exception { // template void A::f(){ // U u; // } + @Test public void testTemplateScopes_a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1382,6 +1420,7 @@ public void testTemplateScopes_a() throws Exception { // template < class T > void f(T); // }; // template void A::f<>(U){} + @Test public void testTemplateScopes_b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1416,6 +1455,7 @@ public void testTemplateScopes_b() throws Exception { // // A ab; // A ac; + @Test public void testEnclosingScopes_a() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -1431,8 +1471,8 @@ public void testEnclosingScopes_a() throws Exception { assertInstance(b0.getScope(), ICPPTemplateScope.class); - IScope ts0 = ((ICPPClassType) b0.getSpecializedBinding()).getScope(); - IScope ts1 = ((ICPPClassType) b1.getSpecializedBinding()).getScope(); + IScope ts0 = b0.getSpecializedBinding().getScope(); + IScope ts1 = b1.getSpecializedBinding().getScope(); assertInstance(ts0, ICPPTemplateScope.class); @@ -1457,6 +1497,7 @@ public void testEnclosingScopes_a() throws Exception { // A::B acb; // A::B adb; // } + @Test public void testEnclosingScopes_b() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -1484,6 +1525,7 @@ public void testEnclosingScopes_b() throws Exception { // }; // // X::Y::Z xayz; + @Test public void testEnclosingScopes_c() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -1508,6 +1550,7 @@ public void testEnclosingScopes_c() throws Exception { // }; // // X::N n; + @Test public void testEnclosingScopes_d() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -1534,6 +1577,7 @@ public void testEnclosingScopes_d() throws Exception { // template<> template<> void A::g(int,char); // template<> template<> void A::g(int,char); // template<> void A::h(int) { } + @Test public void test14_7_3s16() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1596,6 +1640,7 @@ public void test14_7_3s16() throws Exception { // template void N::B::f(C) { // C b; // C is the template parameter, not N::C // } + @Test public void test14_6_1s6() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1629,6 +1674,7 @@ public void test14_6_1s6() throws Exception { // template class Array {}; // template void sort(Array &); // template void sort<>(Array &); + @Test public void testBug90689_ExplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1655,6 +1701,7 @@ public void testBug90689_ExplicitInstantiation() throws Exception { // template class Array; // template void sort(Array& v) { } // template void sort(Array&); // argument is deduced here + @Test public void test14_7_2s2_ExplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1678,6 +1725,7 @@ public void test14_7_2s2_ExplicitInstantiation() throws Exception { // A* p; // void f() { this; } // }; + @Test public void testBug74204() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1698,6 +1746,7 @@ public void testBug74204() throws Exception { // template void g(T t){ // f(t); // } + @Test public void testDeferredFunctionTemplates() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1717,6 +1766,7 @@ public void testDeferredFunctionTemplates() throws Exception { // init(a); // } // }; + @Test public void testRelaxationForTemplateInheritance() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1743,6 +1793,7 @@ public void testRelaxationForTemplateInheritance() throws Exception { // i->foo; i[0].foo; // } // } + @Test public void testBug91707() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1773,6 +1824,7 @@ public void testBug91707() throws Exception { // A::_T t; // (*t).i; // } + @Test public void testBug98961() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1796,6 +1848,7 @@ public void testBug98961() throws Exception { // } // void begin(); // }; + @Test public void testBug98784() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1811,6 +1864,7 @@ public void testBug98784() throws Exception { // void m(){ // f(A(1)); // } + @Test public void testBug99254a() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPConstructor ctor = bh.assertNonProblem("A(T t)", "A", ICPPConstructor.class); @@ -1837,6 +1891,7 @@ public void testBug99254a() throws Exception { // void f(B* b){ // b->add(core::A(10, 2)); // } + @Test public void testBug99254b() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPConstructor ctor = bh.assertNonProblem("A(T x, T y)", "A", ICPPConstructor.class); @@ -1861,6 +1916,7 @@ public void testBug99254b() throws Exception { // void f(B* b){ // b->add(A(10)); // } + @Test public void testBug99254c() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPConstructor ctor = bh.assertNonProblem("A(T)", "A", ICPPConstructor.class); @@ -1876,6 +1932,7 @@ public void testBug99254c() throws Exception { assertSame(add, add2); } + @Test public void testBug98666() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse("A::template B b;", CPP); @@ -1896,6 +1953,7 @@ public void testBug98666() throws Exception { // template template // struct A::C::B{}; // A::C::B ab; + @Test public void testBug90678() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -1928,6 +1986,7 @@ public void testBug90678() throws Exception { // int f(int); // #2 // int k = f(1); // uses #2 // int l = f<>(1); // uses #1 + @Test public void testBug95208() throws Exception { String content = getAboveComment(); IASTTranslationUnit tu = parse(content, CPP); @@ -1957,6 +2016,7 @@ public void testBug95208() throws Exception { // const int local = 10; // A broken; // }; + @Test public void testBug103578() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -1977,6 +2037,7 @@ public void testBug103578() throws Exception { // A< B > a; // a.base; // } + @Test public void testBug103715() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2002,6 +2063,7 @@ public void testBug103715() throws Exception { // }; // void complex::f(float){ // } + @Test public void testBug74276() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2028,6 +2090,7 @@ public void testBug74276() throws Exception { // void m(){ // myType t; // } + @Test public void testBug105852() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2051,6 +2114,7 @@ public void testBug105852() throws Exception { // B k; // k.c; // } + @Test public void testBug105769() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2067,6 +2131,7 @@ public void testBug105769() throws Exception { // template <> C(char * c) : blah(c) {} // template <> C(wchar_t * c) : blah(c) {} // }; + @Test public void testBug162230() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2102,6 +2167,7 @@ public void testBug162230() throws Exception { // template< class T > class C {}; // typedef struct C CInt; + @Test public void testBug169628() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2126,6 +2192,7 @@ public void testBug169628() throws Exception { // makeClosure(this, &A::m1); // } // }; + @Test public void testBug201204() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("makeClosure(this", 11, ICPPFunction.class); @@ -2152,6 +2219,7 @@ public void testBug201204() throws Exception { // func(c, &C::m1); // func(d, &C::m2); // } + @Test public void testBug233889() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn1 = bh.assertNonProblem("func(c", 4, ICPPFunction.class); @@ -2175,6 +2243,7 @@ public void testBug233889() throws Exception { // int main(map x) { // GetPair(x, 1); // } + @Test public void testBug229917a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("GetPair(x", 7, ICPPFunction.class); @@ -2192,6 +2261,7 @@ public void testBug229917a() throws Exception { // // template // typename _C::value_type GetPair(_C& collection, typename _C::value_type::first_type key); + @Test public void testBug229917b() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); IBinding b0 = bh.assertNonProblem("value_type GetPair", 10, IBinding.class); @@ -2211,6 +2281,7 @@ public void testBug229917b() throws Exception { // void f(C& str) { // str.m(); // } + @Test public void testBug232086() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction b0 = bh.assertNonProblem("m();", 1, ICPPFunction.class); @@ -2234,6 +2305,7 @@ public void testBug232086() throws Exception { // foo(a); // bar(ca); // } + @Test public void testBug214646() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); @@ -2266,6 +2338,7 @@ public void testBug214646() throws Exception { // func(a1); // func(a2); // } + @Test public void testFunctionTemplate_245049a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class); @@ -2289,6 +2362,7 @@ public void testFunctionTemplate_245049a() throws Exception { // func(a1); // func(a2); // } + @Test public void testFunctionTemplate_245049b() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction b0 = bh.assertNonProblem("func(a1)", 4, ICPPFunction.class); @@ -2312,6 +2386,7 @@ public void testFunctionTemplate_245049b() throws Exception { // using ns::pair; // using ns::make_pair; // pair p = make_pair(1, 2); + @Test public void testFunctionTemplateWithUsing() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class); @@ -2321,6 +2396,7 @@ public void testFunctionTemplateWithUsing() throws Exception { // void main() { // f(1); // } + @Test public void testFunctionTemplateImplicitInstantiation() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -2342,6 +2418,7 @@ public void testFunctionTemplateImplicitInstantiation() throws Exception { // void test() { // waldo(+[]() {}); // } + @Test public void testFunctionTemplateWithLambdaArgument_443361() throws Exception { parseAndCheckBindings(); } @@ -2359,6 +2436,7 @@ public void testFunctionTemplateWithLambdaArgument_443361() throws Exception { // void test(B x) { // f(a(x)); // } + @Test public void testFunctionTemplate_264963() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("f(a(x));", 1, ICPPFunction.class); @@ -2374,6 +2452,7 @@ public void testFunctionTemplate_264963() throws Exception { // void test() { // f(&A::m); // } + @Test public void testFunctionTemplate_266532() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("f(&A::m);", 1, ICPPFunction.class); @@ -2390,6 +2469,7 @@ public void testFunctionTemplate_266532() throws Exception { // void test(A p) { // f(p); // } + @Test public void testFunctionTemplate_272848a() throws Exception { parseAndCheckBindings(); } @@ -2406,6 +2486,7 @@ public void testFunctionTemplate_272848a() throws Exception { // void test(A p) { // f(p); // } + @Test public void testFunctionTemplate_272848b() throws Exception { parseAndCheckBindings(); } @@ -2419,6 +2500,7 @@ public void testFunctionTemplate_272848b() throws Exception { // void test(int* x) { // f(x); // } + @Test public void testFunctionTemplate_309564() throws Exception { parseAndCheckBindings(); } @@ -2428,6 +2510,7 @@ public void testFunctionTemplate_309564() throws Exception { // void test() { // f1(&f2); // } + @Test public void testSimplifiedFunctionTemplateWithFunctionPointer_281783() throws Exception { parseAndCheckBindings(); } @@ -2445,6 +2528,7 @@ public void testSimplifiedFunctionTemplateWithFunctionPointer_281783() throws Ex // void test(A x) { // f1(x, &f2); // } + @Test public void testFunctionTemplateWithFunctionPointer_281783() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("f1(x, &f2);", 2, ICPPFunction.class); @@ -2471,6 +2555,7 @@ public void testFunctionTemplateWithFunctionPointer_281783() throws Exception { // // foo -> CPPMethodTemplateSpecialization // // foo -> CPPMethodInstance // } + @Test public void testCPPConstructorTemplateSpecialization() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2493,6 +2578,7 @@ public void testCPPConstructorTemplateSpecialization() throws Exception { // template const T& (max)(const T& lhs, const T& rhs) { // return (lhs < rhs ? rhs : lhs); // } + @Test public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2542,6 +2628,7 @@ public void testNestedFuncTemplatedDeclarator_bug190241() throws Exception { // }; // // void f(B::tb r) {} + @Test public void testTemplateTypedef_214447() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2576,6 +2663,7 @@ public void testTemplateTypedef_214447() throws Exception { // }; // // void f(Vec::reference r) {} + @Test public void testRebindPattern_214447a() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2616,6 +2704,7 @@ public void testRebindPattern_214447a() throws Exception { // }; // // void f(Vec::reference r) {} + @Test public void testRebindPattern_214447b() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2655,6 +2744,7 @@ public void testRebindPattern_214447b() throws Exception { // }; // // void f(map::value_type r) {} + @Test public void testRebindPattern_236197() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2687,6 +2777,7 @@ public void testRebindPattern_236197() throws Exception { // }; // // void main(Iter::iter_reference r); + @Test public void testSpecializationSelection_229218() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2713,6 +2804,7 @@ public void testSpecializationSelection_229218() throws Exception { // struct B::type> {}; // // typename B, int>::type a; + @Test public void testSpecializationSelection_509255a() throws Exception { parseAndCheckBindings(); } @@ -2729,6 +2821,7 @@ public void testSpecializationSelection_509255a() throws Exception { // A a; // waldo(a, 1); // } + @Test public void testSpecializationSelection_509255b() throws Exception { parseAndCheckBindings(); } @@ -2800,6 +2893,7 @@ public void testSpecializationSelection_509255b() throws Exception { // void test() { // waldo(f([]() {})); // } + @Test public void testSpecializationSelection_509255c() throws Exception { parseAndCheckBindings(); } @@ -2817,6 +2911,7 @@ public void testSpecializationSelection_509255c() throws Exception { // }; // // B::b::a x; + @Test public void testDefaultTemplateParameter() throws Exception { CPPASTNameBase.sAllowNameComputation = true; IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -2847,6 +2942,7 @@ public void testDefaultTemplateParameter() throws Exception { // A x; // AI y; // AT z; + @Test public void testDefaultTemplateParameter_281781() throws Exception { parseAndCheckBindings(); } @@ -2867,6 +2963,7 @@ public void testDefaultTemplateParameter_281781() throws Exception { // D d; // foo(d); // } + @Test public void testUserDefinedConversions_224364() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class); @@ -2887,6 +2984,7 @@ public void testUserDefinedConversions_224364() throws Exception { // D d; // foo(d); // } + @Test public void testUserDefinedConversions_224364a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("foo(d)", 3, ICPPFunction.class); @@ -2910,6 +3008,7 @@ public void testUserDefinedConversions_224364a() throws Exception { // Z foo(Z z) {return z;} // // Z z= foo(*new E()); + @Test public void testUserDefinedConversions_224364b() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("foo(*new", 3, ICPPFunction.class); @@ -2934,6 +3033,7 @@ public void testUserDefinedConversions_224364b() throws Exception { // C cx; // foo(cx); // } + @Test public void testUserDefinedConversions_226231() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPFunction fn = bh.assertNonProblem("foo(cx", 3, ICPPFunction.class); @@ -2953,6 +3053,7 @@ public void testUserDefinedConversions_226231() throws Exception { // void ref(C c) { // return foo(c); // } + @Test public void testUserDefinedConversions_239023() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("foo(c);", 3); @@ -2963,6 +3064,7 @@ public void testUserDefinedConversions_239023() throws Exception { // // const int i= 1; // A a1; + @Test public void testNonTypeArgumentIsIDExpression_229942a() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2982,6 +3084,7 @@ public void testNonTypeArgumentIsIDExpression_229942a() throws Exception { // // const int i= 1; // }; + @Test public void testNonTypeArgumentIsIDExpression_229942b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -2996,6 +3099,7 @@ public void testNonTypeArgumentIsIDExpression_229942b() throws Exception { // // const int i= 1; // A a1; + @Test public void testExpressionArgumentIsExpression_229942() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -3011,6 +3115,7 @@ public void testExpressionArgumentIsExpression_229942() throws Exception { // // const int i= 1; // A a1; + @Test public void testTypeIdOperatorArgumentIsUnaryExpression_229942() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -3024,6 +3129,7 @@ public void testTypeIdOperatorArgumentIsUnaryExpression_229942() throws Exceptio // template class A {}; // template< class T1, class T2, int q1, int q2> // class A< C, C > {}; + @Test public void testTemplateIdAsTemplateArgumentIsTypeId_229942() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -3054,6 +3160,7 @@ public void testTemplateIdAsTemplateArgumentIsTypeId_229942() throws Exception { // inline const A foo(const A at) { // return at; // } + @Test public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("T> at) {", 1); @@ -3077,6 +3184,7 @@ public void testTypeIdAsTemplateArgumentIsTypeId_229942a() throws Exception { // template // inline const void foo(void (*f)(A), T* t) { // disallowed, but we're testing the AST // } + @Test public void testTypeIdAsTemplateArgumentIsTypeId_229942b() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); NameCollector col = new NameCollector(); @@ -3093,6 +3201,7 @@ public void testTypeIdAsTemplateArgumentIsTypeId_229942b() throws Exception { // typedef int td; // template<> class Alias { // }; + @Test public void testNonAmbiguityCase_229942() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP); NameCollector col = new NameCollector(); @@ -3119,6 +3228,7 @@ public void testNonAmbiguityCase_229942() throws Exception { // // C c1; // OK since C++17 via implicit deduction guide using default template argument // C<> c2; // ok - default args + @Test public void testMissingTemplateArgumentLists() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertProblem("B b1", 1); @@ -3136,6 +3246,7 @@ public void testMissingTemplateArgumentLists() throws Exception { // template inline void TestClass::fun1(void) { // member1 = 0; // } + @Test public void testDefinitionOfClassTemplateWithNonTypeParameter() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPMethod f1 = ba.assertNonProblem("fun1(void);", 4, ICPPMethod.class); @@ -3162,6 +3273,7 @@ public void testDefinitionOfClassTemplateWithNonTypeParameter() throws Exception // void ref() { // A::B<> b; // } + @Test public void testNestedTemplateDefinitionParameter() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPTemplateTypeParameter T3a = ba.assertNonProblem("T3 f", 2, ICPPTemplateTypeParameter.class); @@ -3178,6 +3290,7 @@ public void testNestedTemplateDefinitionParameter() throws Exception { // A::X x; // A::Y y; // A::Z z; + @Test public void testNonTypeArgumentDisambiguation_233460() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPClassType b2 = ba.assertNonProblem("A", 7, ICPPClassType.class, ICPPTemplateInstance.class); @@ -3207,6 +3320,7 @@ public void testNonTypeArgumentDisambiguation_233460() throws Exception { // // A::X x; //3 should be an error // A::Y y; //4 should be an error + @Test public void testNonTypeBooleanArgumentDisambiguation() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -3238,6 +3352,7 @@ public void testNonTypeBooleanArgumentDisambiguation() throws Exception { // bar(t); // baz(); // } + @Test public void testBug207871() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -3269,6 +3384,7 @@ public void testBug207871() throws Exception { // public: // C go(); // }; + @Test public void testDeferredNonTypeArgument() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPDeferredClassInstance ci = ba.assertNonProblem("C", 4, ICPPDeferredClassInstance.class); @@ -3281,6 +3397,7 @@ public void testDeferredNonTypeArgument() throws Exception { // class A {}; // // A aint; // should be an error + @Test public void testTypeArgumentToNonTypeParameter() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertProblem("A", 6); @@ -3301,6 +3418,7 @@ public void testTypeArgumentToNonTypeParameter() throws Exception { // template // inline This::This() : That(I) { // } + @Test public void testParameterReferenceInChainInitializer_a() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -3334,6 +3452,7 @@ public void testParameterReferenceInChainInitializer_a() throws Exception { // template // inline This::This() : That() { // } + @Test public void testParameterReferenceInChainInitializer_b() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -3356,6 +3475,7 @@ public void testParameterReferenceInChainInitializer_b() throws Exception { // class A {}; // // C ca5L; + @Test public void testIntegralConversionInPartialSpecializationMatching_237914() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPTemplateInstance ctps = ba.assertNonProblem("C", 7, ICPPTemplateInstance.class, ICPPClassType.class); @@ -3376,6 +3496,7 @@ public void testIntegralConversionInPartialSpecializationMatching_237914() throw // void xx() { // ca5L.test= 0; // } + @Test public void testIntegralConversionInSpecializationMatching_237914() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPSpecialization ctps = ba.assertNonProblem("C", 7, ICPPSpecialization.class, ICPPClassType.class); @@ -3404,6 +3525,7 @@ public void testIntegralConversionInSpecializationMatching_237914() throws Excep // void test() { // waldo(1); // } + @Test public void testIntegralConversionOperator_495091a() throws Exception { parseAndCheckBindings(); } @@ -3430,6 +3552,7 @@ public void testIntegralConversionOperator_495091a() throws Exception { // void test() { // waldo(1); // } + @Test public void testIntegralConversionOperator_495091b() throws Exception { parseAndCheckBindings(); } @@ -3444,6 +3567,7 @@ public void testIntegralConversionOperator_495091b() throws Exception { // public: // B(const B& other) : A(other) {} // }; + @Test public void testChainInitializerLookupThroughDeferredClassBase() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("A(other", 1); @@ -3459,6 +3583,7 @@ public void testChainInitializerLookupThroughDeferredClassBase() throws Exceptio // typedef int INT; // A x = waldo([](int data) { return false; }); // } + @Test public void testLambda_430428() throws Exception { parseAndCheckBindings(); } @@ -3477,6 +3602,7 @@ public void testLambda_430428() throws Exception { // B::foo(static_cast(t)); // } // }; + @Test public void testMemberLookupThroughDeferredClassBase() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("foo(s", 3); @@ -3492,6 +3618,7 @@ public void testMemberLookupThroughDeferredClassBase() throws Exception { // }; // // typedef result::type waldo; + @Test public void testDependentBaseLookup_408314a() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ITypedef waldo = bh.assertNonProblem("waldo"); @@ -3514,6 +3641,7 @@ public void testDependentBaseLookup_408314a() throws Exception { // }; // // typedef A::result::type waldo; + @Test public void testDependentBaseLookup_408314b() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ITypedef waldo = bh.assertNonProblem("waldo"); @@ -3536,6 +3664,7 @@ public void testDependentBaseLookup_408314b() throws Exception { // }; // // typedef A::result::type waldo; + @Test public void testDependentBaseLookup_408314c() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ITypedef waldo = bh.assertNonProblem("waldo"); @@ -3553,6 +3682,7 @@ public void testDependentBaseLookup_408314c() throws Exception { // inline int A::bar() const { // return foo(); // } + @Test public void testMemberReferenceFromTemplatedMethodDefinition_238232() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("foo();", 3); @@ -3578,6 +3708,7 @@ public void testMemberReferenceFromTemplatedMethodDefinition_238232() throws Exc // typedef detail::assoc_find filter; // }; // } + @Test public void testBug238180_ArrayOutOfBounds() throws Exception { // The code above used to trigger an ArrayOutOfBoundsException parse(getAboveComment(), CPP); @@ -3597,6 +3728,7 @@ public void testBug238180_ArrayOutOfBounds() throws Exception { // typedef A type; // }; // } // detail + @Test public void testBug238180_ClassCast() throws Exception { // the code above used to trigger a ClassCastException BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); @@ -3619,6 +3751,7 @@ public void testBug238180_ClassCast() throws Exception { // void bla(int g) { // test(new X(g)); // } + @Test public void testBug239586_ClassCast() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -3627,6 +3760,7 @@ public void testBug239586_ClassCast() throws Exception { // static int x; // }; // template int CT::x = sizeof(T); + @Test public void testUsingTemplParamInInitializerOfStaticField() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPTemplateTypeParameter t = ba.assertNonProblem("T)", 1, ICPPTemplateTypeParameter.class); @@ -3651,6 +3785,7 @@ public void testUsingTemplParamInInitializerOfStaticField() throws Exception { // template <> struct Waldo<42> { typedef int type; }; // // Waldo::type foo(); // ERROR + @Test public void testDependentIdExprNamingStaticMember_508254() throws Exception { parseAndCheckBindings(); } @@ -3697,6 +3832,7 @@ public void testDependentIdExprNamingStaticMember_508254() throws Exception { // cb.b = 6; // func(cb); // } + @Test public void testTemplateMetaProgramming_245027() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ICPPMethod method = ba.assertNonProblem("method();", 6, ICPPMethod.class); @@ -3723,6 +3859,7 @@ public void testTemplateMetaProgramming_245027() throws Exception { // int x; // ns1::A<(sizeof(probe(x)) == 1)>::m(x); // } + @Test public void testNonTypeTemplateParameter_252108() throws Exception { BindingAssertionHelper ba = new AST2AssertionHelper(getAboveComment(), CPP); ba.assertNonProblem("x))", 1, ICPPVariable.class); @@ -3743,6 +3880,7 @@ public void testNonTypeTemplateParameter_252108() throws Exception { // > > > > > // > > > > > // type; + @Test public void testNestedArguments_246079() throws Throwable { final Throwable[] th = { null }; Thread t = new Thread() { @@ -3768,6 +3906,7 @@ public void run() { // void foo(T t); // }; // template void A::foo(T t) {} + @Test public void testBug177418() throws Exception { IASTTranslationUnit tu = parse(getAboveComment(), CPP, ScannerKind.GNU, true); @@ -3806,6 +3945,7 @@ public void testBug177418() throws Exception { // template T * CT::instance (void) { // return new CT; // } + @Test public void testNewOfThisTemplate() throws Exception { parseAndCheckBindings(getAboveComment(), CPP); } @@ -3814,6 +3954,7 @@ public void testNewOfThisTemplate() throws Exception { // class X { // friend void f<>(int); // }; + @Test public void testFunctionSpecializationAsFriend() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -3841,6 +3982,7 @@ public void testFunctionSpecializationAsFriend() throws Exception { // template typename XT::mytype1 XT::m1() {} // template typename XT::mytype2 XT::m2() {} // XT::mytype3 XT::m3() {} + @Test public void testMethodImplWithNonDeferredType() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -3866,6 +4008,7 @@ public void testMethodImplWithNonDeferredType() throws Exception { // template void f(T); // }; // template void A::f(T){} + @Test public void testClassTemplateMemberFunctionTemplate_104262() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -3889,6 +4032,7 @@ public void testClassTemplateMemberFunctionTemplate_104262() throws Exception { // }; // template template void XT::Nested::m(V) { // } + @Test public void testQualifiedMethodTemplate() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -3918,6 +4062,7 @@ public void testQualifiedMethodTemplate() throws Exception { // void test() { // waldo(1); // } + @Test public void testMethodTemplate_497535a() throws Exception { parseAndCheckBindings(); } @@ -3940,6 +4085,7 @@ public void testMethodTemplate_497535a() throws Exception { // void test() { // waldo(1); // } + @Test public void testMethodTemplate_497535b() throws Exception { parseAndCheckBindings(); } @@ -3950,6 +4096,7 @@ public void testMethodTemplate_497535b() throws Exception { // XT xt; // xt.partial; // } + @Test public void testDefaultArgsWithPartialSpecialization() throws Exception { parseAndCheckBindings(); } @@ -3961,6 +4108,7 @@ public void testDefaultArgsWithPartialSpecialization() throws Exception { // this->a= 1; // } // }; + @Test public void testFieldReference_257186() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -3983,6 +4131,7 @@ public void testFieldReference_257186() throws Exception { // f(b); g(b); h(b); m(b); // } // }; + @Test public void testUnknownReferences_257194() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4006,6 +4155,7 @@ public void testUnknownReferences_257194() throws Exception { // v.x; v.y(); // } // }; + @Test public void testTypeOfUnknownReferences_257194a() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4031,6 +4181,7 @@ public void testTypeOfUnknownReferences_257194a() throws Exception { // v->x; v->y(); // } // }; + @Test public void testTypeOfUnknownReferences_257194b() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4056,6 +4207,7 @@ public void testTypeOfUnknownReferences_257194b() throws Exception { // typename T::F(); // } // }; + @Test public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4094,6 +4246,7 @@ public void testTypeVsExpressionInArgsOfDependentTemplateID_257194() throws Exce // void test(B >::reference p) { // func(p); // } + @Test public void testTypedefReference_259871() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("func(p)", 4, ICPPFunction.class); @@ -4114,6 +4267,7 @@ public void testTypedefReference_259871() throws Exception { // void test() { // new C(&B::m); // } + @Test public void testTypedef() throws Exception { parseAndCheckBindings(); } @@ -4137,6 +4291,7 @@ public void testTypedef() throws Exception { // auto s2 = s1 += ""; // auto s3 = s2.append("foo"); // } + @Test public void testTypedefPreservation_380498a() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPVariable s1 = ba.assertNonProblem("s1"); @@ -4161,6 +4316,7 @@ public void testTypedefPreservation_380498a() throws Exception { // void test(const vector& v) { // auto it = v.begin(); // } + @Test public void testTypedefPreservation_380498b() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPVariable it = ba.assertNonProblem("it =", "it", ICPPVariable.class); @@ -4202,6 +4358,7 @@ public void testTypedefPreservation_380498b() throws Exception { // for (auto s : v) { // } // } + @Test public void testTypedefPreservation_380498c() throws Exception { BindingAssertionHelper ba = getAssertionHelper(); ICPPVariable s = ba.assertNonProblem("s :", "s", ICPPVariable.class); @@ -4222,6 +4379,7 @@ public void testTypedefPreservation_380498c() throws Exception { // void test(A p) { // p.waldo(); // } + @Test public void testTypeTraitWithQualifier_511143() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -4243,6 +4401,7 @@ public void testTypeTraitWithQualifier_511143() throws Exception { // new A(&B::m); // } // }; + @Test public void testNestedTemplates_259872a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("A", 9, ICPPClassType.class); @@ -4268,6 +4427,7 @@ public void testNestedTemplates_259872a() throws Exception { // new A(&B::m); // } // }; + @Test public void testNestedTemplates_259872b() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("A", 9, ICPPClassType.class); @@ -4285,6 +4445,7 @@ public void testNestedTemplates_259872b() throws Exception { // template // DumbPtr::~DumbPtr/**/ () { // } + @Test public void testCtorWithTemplateID_259600() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4300,6 +4461,7 @@ public void testCtorWithTemplateID_259600() throws Exception { // }; // template template XT::XT/**/(X* a) {} // template template XT::XT/**/(X& a) {} + @Test public void testCtorTemplateWithTemplateID_259600() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4324,6 +4486,7 @@ public void testCtorTemplateWithTemplateID_259600() throws Exception { // void test() { // XT::TD x; // } + @Test public void testResolutionOfUnknownBindings_262163() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4358,6 +4521,7 @@ public void testResolutionOfUnknownBindings_262163() throws Exception { // void test(BasicString s) { // s.substr(0); // } + @Test public void testResolutionOfUnknownBindings_262328() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("substr(0)", 6, ICPPMethod.class); @@ -4371,6 +4535,7 @@ public void testResolutionOfUnknownBindings_262328() throws Exception { // field.m(c); // } // }; + @Test public void testResolutionOfUnknownFunctions() throws Exception { parseAndCheckBindings(); } @@ -4383,6 +4548,7 @@ public void testResolutionOfUnknownFunctions() throws Exception { // field[0].m(c); // } // }; + @Test public void testResolutionOfUnknownArrayAccess() throws Exception { parseAndCheckBindings(); } @@ -4396,6 +4562,7 @@ public void testResolutionOfUnknownArrayAccess() throws Exception { // CT x; // x.append(3, 'c'); // } + @Test public void testConflictInTemplateArgumentDeduction() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -4417,6 +4584,7 @@ public void testConflictInTemplateArgumentDeduction() throws Exception { // void test(const C& p) { // p.m(); // } + @Test public void testConversionSequence_263159() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); ICPPMethod m = bh.assertNonProblem("m();", 1, ICPPMethod.class); @@ -4437,6 +4605,7 @@ public void testConversionSequence_263159() throws Exception { // A make_A(C* p) { // return A(p); // } + @Test public void testForwardDeclarations_264109() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("A make_A(C* p) {", 4, ICPPTemplateInstance.class); @@ -4452,6 +4621,7 @@ public void testForwardDeclarations_264109() throws Exception { // int* iptr; // any(CT(iptr)); // } + @Test public void testConstructorTemplateInClassTemplate_264314() throws Exception { parseAndCheckBindings(); } @@ -4469,6 +4639,7 @@ public void testConstructorTemplateInClassTemplate_264314() throws Exception { // func(x, xint); // func(y, xy, xint); // } + @Test public void testDistinctDeferredInstances_264367() throws Exception { parseAndCheckBindings(); } @@ -4478,6 +4649,7 @@ public void testDistinctDeferredInstances_264367() throws Exception { // m(0); // ok with a conversion from 0 to T // } // }; + @Test public void testUnknownParameter_264988() throws Exception { parseAndCheckBindings(); } @@ -4489,6 +4661,7 @@ public void testUnknownParameter_264988() throws Exception { // // int x = A<0>::e; // A<0>::E y; + @Test public void testEnumeratorInTemplateInstance_265070() throws Exception { parseAndCheckBindings(); } @@ -4500,6 +4673,7 @@ public void testEnumeratorInTemplateInstance_265070() throws Exception { // CT i; // getline2(i); // } + @Test public void testAmbiguousDeclaratorInFunctionTemplate_265342() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); bh.assertNonProblem("getline2(i)", 8, ICPPTemplateInstance.class); @@ -4518,6 +4692,7 @@ public void testAmbiguousDeclaratorInFunctionTemplate_265342() throws Exception // }; // }; // }; + @Test public void testOwnerOfFriendTemplate_265671() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); IFunction f = bh.assertNonProblem("f1(", 2, IFunction.class); @@ -4551,6 +4726,7 @@ public void testOwnerOfFriendTemplate_265671() throws Exception { // f(a); // a.m(a); // } + @Test public void testOwnerOfFriendTemplateFunction_408181() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ICPPFunction f = bh.assertNonProblemOnFirstIdentifier("f(a)"); @@ -4563,6 +4739,7 @@ public void testOwnerOfFriendTemplateFunction_408181() throws Exception { // g(t); // } // template void g(T t) {} + @Test public void testDependentNameReferencingLaterDeclaration_265926a() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); IFunction gref = bh.assertNonProblem("g(t)", 1); @@ -4588,6 +4765,7 @@ public void testDependentNameReferencingLaterDeclaration_265926a() throws Except // class C { // void a() {}; // }; + @Test public void testDependentNameReferencingLaterDeclaration_265926b() throws Exception { parseAndCheckBindings(); } @@ -4599,6 +4777,7 @@ public void testDependentNameReferencingLaterDeclaration_265926b() throws Except // xt.operator T*()->something(); // } // }; + @Test public void testDeferredConversionOperator() throws Exception { parseAndCheckBindings(); } @@ -4612,6 +4791,7 @@ public void testDeferredConversionOperator() throws Exception { // X x; // } // }; + @Test public void testFriendClassTemplate_266992() throws Exception { parseAndCheckBindings(); } @@ -4623,6 +4803,7 @@ public void testFriendClassTemplate_266992() throws Exception { // void test() { // S(a); // } + @Test public void testFunctionTemplateWithArrayReferenceParameter_269926() throws Exception { parseAndCheckBindings(); } @@ -4635,6 +4816,7 @@ public void testFunctionTemplateWithArrayReferenceParameter_269926() throws Exce // void test() { // S(a); // } + @Test public void testFunctionTemplateWithArrayReferenceParameter_394024() throws Exception { parseAndCheckBindings(); } @@ -4652,6 +4834,7 @@ public void testFunctionTemplateWithArrayReferenceParameter_394024() throws Exce // void test(B p) { // f(p); // } + @Test public void testTemplateConversionOperator_271948a() throws Exception { parseAndCheckBindings(); } @@ -4671,6 +4854,7 @@ public void testTemplateConversionOperator_271948a() throws Exception { // void test(B x) { // f(x); // } + @Test public void testTemplateConversionOperator_271948b() throws Exception { parseAndCheckBindings(); } @@ -4689,6 +4873,7 @@ public void testTemplateConversionOperator_271948b() throws Exception { // }; // // Mat x = MatExpr(); + @Test public void testOverloadedConversionOperators_550397() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -4696,6 +4881,7 @@ public void testOverloadedConversionOperators_550397() throws Exception { // template struct ST{}; // template class T> class CT {}; // typedef CT TDef; + @Test public void testUsingTemplateTemplateParameter_279619() throws Exception { parseAndCheckBindings(); } @@ -4705,6 +4891,7 @@ public void testUsingTemplateTemplateParameter_279619() throws Exception { // int a[2]; // T<2>(a); // } + @Test public void testInstantiationOfArraySize_269926() throws Exception { parseAndCheckBindings(); } @@ -4714,6 +4901,7 @@ public void testInstantiationOfArraySize_269926() throws Exception { // }; // void CT::init(void) { // } + @Test public void testMethodSpecialization_322988() throws Exception { parseAndCheckBindings(); } @@ -4775,6 +4963,7 @@ public void testMethodSpecialization_322988() throws Exception { // waldo(X()); // waldo(Y()); // } + @Test public void testInheritedConstructor_489710() throws Exception { parseAndCheckBindings(); } @@ -4788,6 +4977,7 @@ public void testInheritedConstructor_489710() throws Exception { // void test(A x) { // f(x); // } + @Test public void testInlineFriendFunction_284690() throws Exception { parseAndCheckBindings(); } @@ -4806,6 +4996,7 @@ public void testInlineFriendFunction_284690() throws Exception { // void test(A x) { // f(x); // } + @Test public void testInlineFriendFunction_287409() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -4826,6 +5017,7 @@ public void testInlineFriendFunction_287409() throws Exception { // template<> struct CreateTL { // typedef NullType Type; // }; + @Test public void testDefaultArgument_289132() throws Exception { parseAndCheckBindings(); } @@ -4838,6 +5030,7 @@ public void testDefaultArgument_289132() throws Exception { // n(); // must be a problem // } // }; + @Test public void testResolutionOfNonDependentNames_293052() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -4863,6 +5056,7 @@ public void testResolutionOfNonDependentNames_293052() throws Exception { // f4(i); // f3(&cd); // must be a problem, cd is const // } + @Test public void testArgumentDeduction_293409() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -4885,6 +5079,7 @@ public void testArgumentDeduction_293409() throws Exception { // f(ch, cchar); // f(ch, cint); // } + @Test public void testFunctionTemplateOrdering_293468() throws Exception { parseAndCheckBindings(); } @@ -4902,6 +5097,7 @@ public void testFunctionTemplateOrdering_293468() throws Exception { // const int* a; // func1 (a); // } + @Test public void testFunctionTemplateOrdering_294539() throws Exception { parseAndCheckBindings(); } @@ -4913,6 +5109,7 @@ public void testFunctionTemplateOrdering_294539() throws Exception { // int main() { // foo(0); // } + @Test public void testFunctionTemplateOrdering_DR1395_388805() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -4939,6 +5136,7 @@ public void testFunctionTemplateOrdering_DR1395_388805() throws Exception { // int main() { // foo(0); // ERROR HERE // } + @Test public void testFunctionTemplateOrdering_409094a() throws Exception { parseAndCheckBindings(); } @@ -4968,6 +5166,7 @@ public void testFunctionTemplateOrdering_409094a() throws Exception { // waldo w; // foo(w); // ERROR HERE // } + @Test public void testFunctionTemplateOrdering_409094b() throws Exception { parseAndCheckBindings(); } @@ -4981,6 +5180,7 @@ public void testFunctionTemplateOrdering_409094b() throws Exception { // a= 1 >> 2; // return a; // } + @Test public void testClosingAngleBrackets1_261268() throws Exception { parseAndCheckBindings(); } @@ -4993,6 +5193,7 @@ public void testClosingAngleBrackets1_261268() throws Exception { // a= 1 > > 3; // must be syntax error // return a; // } + @Test public void testClosingAngleBrackets2_261268() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parse(code, CPP, ScannerKind.GNU, false); @@ -5010,6 +5211,7 @@ public void testClosingAngleBrackets2_261268() throws Exception { // y= a < a >> (1+2); // binary expression // a < a >> (1+2); // binary expression via ambiguity // } + @Test public void testClosingAngleBracketsAmbiguity_261268() throws Exception { parseAndCheckBindings(); } @@ -5019,6 +5221,7 @@ public void testClosingAngleBracketsAmbiguity_261268() throws Exception { // int a=1; // a OPASSIGN(>>) 1; // } + @Test public void testTokenPasteShiftROperator_261268() throws Exception { parseAndCheckBindings(); } @@ -5031,6 +5234,7 @@ public void testTokenPasteShiftROperator_261268() throws Exception { // // X::g has the parameter type int& // X x2; // X::f has the parameter type const int& // // X::g has the parameter type const int&& + @Test public void testRValueReferences_294730() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5060,6 +5264,7 @@ public void testRValueReferences_294730() throws Exception { // template void f5(Pack ...); // template void f6(NonPack ...); // template void f7() throw(T...); + @Test public void testFunctionParameterPacks_280909() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5089,6 +5294,7 @@ public void testFunctionParameterPacks_280909() throws Exception { // template class C1 {}; // template class... Pack> class C2 {}; // template class C3 {}; + @Test public void testTemplateParameterPacks_280909() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5118,6 +5324,7 @@ public void testTemplateParameterPacks_280909() throws Exception { // c.b= 1; // c.mem(); // } + @Test public void testParameterPackExpansions_280909() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5134,6 +5341,7 @@ public void testParameterPackExpansions_280909() throws Exception { // template void f1(T*...); // template void f2(T*...); + @Test public void testTemplateParameterPacksAmbiguity_280909() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5153,6 +5361,7 @@ public void testTemplateParameterPacksAmbiguity_280909() throws Exception { // CTx<1> b; // CTx<1,2> c; // } + @Test public void testNonTypeTemplateParameterPack_280909() throws Exception { parseAndCheckBindings(); } @@ -5160,6 +5369,7 @@ public void testNonTypeTemplateParameterPack_280909() throws Exception { // template // struct count { static const int value = sizeof...(Types); // }; + @Test public void testVariadicTemplateExamples_280909a() throws Exception { parseAndCheckBindings(); } @@ -5170,6 +5380,7 @@ public void testVariadicTemplateExamples_280909a() throws Exception { // void g() { // f(add, subtract); // } + @Test public void testVariadicTemplateExamples_280909b() throws Exception { parseAndCheckBindings(); } @@ -5179,12 +5390,14 @@ public void testVariadicTemplateExamples_280909b() throws Exception { // {public: // X(const Mixins&... mixins) : Mixins(mixins)... { } // }; + @Test public void testVariadicTemplateExamples_280909c() throws Exception { parseAndCheckBindings(); } // template class Tuple; // Types is a template type parameter pack // template struct multi array; // Dims is a non-type template parameter pack + @Test public void testVariadicTemplateExamples_280909d() throws Exception { parseAndCheckBindings(); } @@ -5195,6 +5408,7 @@ public void testVariadicTemplateExamples_280909d() throws Exception { // template class Tuple; // Tuple<>* t; // OK: Elements is empty // Tuple* u; // syntax error + @Test public void testVariadicTemplateExamples_280909e() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5215,6 +5429,7 @@ public void testVariadicTemplateExamples_280909e() throws Exception { // Y ya; // okay // Y yb; // okay // Y yc; // okay + @Test public void testVariadicTemplateExamples_280909f() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5238,6 +5453,7 @@ public void testVariadicTemplateExamples_280909f() throws Exception { // template void A::f2() {} // error // template void B::f3() {} // OK // template void B::f4() {} // error + @Test public void testVariadicTemplateExamples_280909g() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5259,6 +5475,7 @@ public void testVariadicTemplateExamples_280909g() throws Exception { // int k = g(5.6); // Y is deduced to be double, Z is deduced to an empty sequence // f(g); // Y for outer f deduced to be // } // int (*)(bool), Z is deduced to an empty sequence + @Test public void testVariadicTemplateExamples_280909h() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5280,6 +5497,7 @@ public void testVariadicTemplateExamples_280909h() throws Exception { // f("aa",3.0); // error: X cannot be deduced // f2(); // okay // } + @Test public void testVariadicTemplateExamples_280909i() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5294,6 +5512,7 @@ public void testVariadicTemplateExamples_280909i() throws Exception { // void g() { // f(0, 0, 0); // Types is the sequence int*, float*, int // } + @Test public void testVariadicTemplateExamples_280909j() throws Exception { parseAndCheckBindings(); } @@ -5305,6 +5524,7 @@ public void testVariadicTemplateExamples_280909j() throws Exception { // f(x, y, z); // Types is deduced to int, float, const int // g(x, y, z); // T1 is deduced to int, Types is deduced to float, int // } + @Test public void testVariadicTemplateExamples_280909k() throws Exception { parseAndCheckBindings(); } @@ -5322,6 +5542,7 @@ public void testVariadicTemplateExamples_280909k() throws Exception { // Y y2; // uses partial specialization. T is int&, Types contains float, double // Y y3; // uses primary template, Types contains int, float, double // int fv = f(g); // okay, Types contains int, float + @Test public void testVariadicTemplateExamples_280909n() throws Exception { parseAndCheckBindings(); } @@ -5333,6 +5554,7 @@ public void testVariadicTemplateExamples_280909n() throws Exception { // Tuple t2; // Types contains two arguments: int and float // Tuple<0> error; // Error: 0 is not a type // } + @Test public void testVariadicTemplateExamples_280909p() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5348,6 +5570,7 @@ public void testVariadicTemplateExamples_280909p() throws Exception { // f(1); // okay: args contains one int argument // f(2, 1.0); // okay: args contains two arguments, an int and a double // } + @Test public void testVariadicTemplateExamples_280909q() throws Exception { parseAndCheckBindings(); } @@ -5356,6 +5579,7 @@ public void testVariadicTemplateExamples_280909q() throws Exception { // template void g(Types... rest) { // f(&rest...); // '&rest...' is a pack expansion, '&rest' is its pattern // } + @Test public void testVariadicTemplateExamples_280909r() throws Exception { parseAndCheckBindings(); } @@ -5380,6 +5604,7 @@ public void testVariadicTemplateExamples_280909r() throws Exception { // f(args); // error: parameter pack 'args' is not expanded // f(h(args...) + args...); // okay: first 'args' expanded within h, second 'args' expanded within f. // } + @Test public void testVariadicTemplateExamples_280909s() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5413,6 +5638,7 @@ public void testVariadicTemplateExamples_280909s() throws Exception { // bool b2 = contains_waldo::value; // bool b2 = contains_waldo::value; // } + @Test public void testRecursiveVariadicTemplate_397828() throws Exception { parseAndCheckBindings(); } @@ -5423,6 +5649,7 @@ public void testRecursiveVariadicTemplate_397828() throws Exception { // }; // // int x = A<>::waldo(0); + @Test public void testVariadicTemplateWithNoArguments_422700() throws Exception { parseAndCheckBindings(); } @@ -5436,6 +5663,7 @@ public void testVariadicTemplateWithNoArguments_422700() throws Exception { // void test() { // bind(&Test::Update); // } + @Test public void testFunctionOrdering_299608() throws Exception { parseAndCheckBindings(); } @@ -5448,6 +5676,7 @@ public void testFunctionOrdering_299608() throws Exception { // f(); // f(0,0) // f(); // f(0,0) // } + @Test public void testDefaultTemplateArgsForFunctionTemplates_294730() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5465,6 +5694,7 @@ public void testDefaultTemplateArgsForFunctionTemplates_294730() throws Exceptio // template class CT {}; // extern template class CT; + @Test public void testExternTemplates_294730() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code); @@ -5486,6 +5716,7 @@ public void testExternTemplates_294730() throws Exception { // eval> eC; // error: C does not match TT in partial specialization // eval> eD; // error: D does not match TT in partial specialization // eval> eE; // error: E does not match TT in partial specialization + @Test public void testExtendingVariadicTemplateTemplateParameters_302282() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5520,6 +5751,7 @@ public void testExtendingVariadicTemplateTemplateParameters_302282() throws Exce // f(1); // g(1); // } + @Test public void testExplicitSpecializations_296427() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5545,6 +5777,7 @@ public void testExplicitSpecializations_296427() throws Exception { // }; // CT::CT() : value_(0) { // } + @Test public void testConstructorOfExplicitSpecialization() throws Exception { parseAndCheckBindings(); } @@ -5559,6 +5792,7 @@ public void testConstructorOfExplicitSpecialization() throws Exception { // void test() { // func(1); // } + @Test public void testBug306213a() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5575,6 +5809,7 @@ public void testBug306213a() throws Exception { // void test() { // func(1); // } + @Test public void testBug306213b() throws Exception { CPPASTNameBase.sAllowRecursionBindings = true; final String code = getAboveComment(); @@ -5593,6 +5828,7 @@ public void testBug306213b() throws Exception { // CT::T1 a; // CT::T2 b; // } + @Test public void testBug306213c() throws Exception { parseAndCheckBindings(); } @@ -5600,6 +5836,7 @@ public void testBug306213c() throws Exception { // template class CT {}; // template<> class CT {}; // template<> class CT {}; + @Test public void testBug311164() throws Exception { CPPASTNameBase.sAllowNameComputation = true; final String code = getAboveComment(); @@ -5630,6 +5867,7 @@ public void testBug311164() throws Exception { // NOTE: If, after refactoring some AST code, this test hangs, check // if any methods that were added during the refactoring need // to be added to ASTComparer.methodsToIgnore. + @Test public void testBug316704() throws Exception { StringBuilder code = new StringBuilder("typedef if_< bool,"); for (int i = 0; i < 50; i++) { @@ -5658,6 +5896,7 @@ public void testBug316704() throws Exception { // A a; // // } + @Test public void testBug377838() throws Exception { parseAndCheckBindings(); } @@ -5673,6 +5912,7 @@ public void testBug377838() throws Exception { // // template void N::f(int&); // template<> void N::f(long&) {} + @Test public void testInlineNamespaces_305980() throws Exception { final String code = getAboveComment(); parseAndCheckBindings(code); @@ -5709,6 +5949,7 @@ public void testInlineNamespaces_305980() throws Exception { // class X {} x; // g(x); // } + @Test public void testUnnamedTypesAsTemplateArgument_316317a() throws Exception { parseAndCheckBindings(); } @@ -5728,6 +5969,7 @@ public void testUnnamedTypesAsTemplateArgument_316317a() throws Exception { // f(unnamed_obj); // OK // f(b); // OK // } + @Test public void testUnnamedTypesAsTemplateArgument_316317b() throws Exception { parseAndCheckBindings(); } @@ -5744,6 +5986,7 @@ public void testUnnamedTypesAsTemplateArgument_316317b() throws Exception { // X x; // (x + 1)->s; // } + @Test public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exception { parseAndCheckBindings(); } @@ -5758,6 +6001,7 @@ public void testOverloadResolutionBetweenMethodTemplateAndFunction() throws Exce // int x = sizeof(f(c)); // const int d[] = { 0 }; // int y = sizeof(f(d)); + @Test public void testOverloadedFunctionTemplate_407579() throws Exception { parseAndCheckBindings(); } @@ -5766,6 +6010,7 @@ public void testOverloadedFunctionTemplate_407579() throws Exception { // void test() { // f(1,1); // } + @Test public void testFunctionParameterPacksInNonFinalPosition_324096() throws Exception { parseAndCheckBindings(); } @@ -5779,6 +6024,7 @@ public void testFunctionParameterPacksInNonFinalPosition_324096() throws Excepti // OutStream out; // out << endl; // } + @Test public void testInstantiationOfEndl_297457() throws Exception { final String code = getAboveComment(); IASTTranslationUnit tu = parseAndCheckBindings(code); @@ -5808,6 +6054,7 @@ public void testInstantiationOfEndl_297457() throws Exception { // ostream out; // out << t << endl; // } + @Test public void testInstantiationOfEndlInTemplate_417700() throws Exception { parseAndCheckBindings(); } @@ -5818,6 +6065,7 @@ public void testInstantiationOfEndlInTemplate_417700() throws Exception { // void test() { // sort(MySort); // } + @Test public void testAdressOfUniqueTemplateInst_326076() throws Exception { parseAndCheckBindings(); } @@ -5833,6 +6081,7 @@ public void testAdressOfUniqueTemplateInst_326076() throws Exception { // f(g, '1'); // f(g, 1); // } + @Test public void testInstantiationOfFunctionTemplateWithOverloadedFunctionSetArgument_326492() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5863,6 +6112,7 @@ public void testInstantiationOfFunctionTemplateWithOverloadedFunctionSetArgument // Ptr parm; // f(parm); // } + @Test public void testADLForTemplateSpecializations_327069() throws Exception { parseAndCheckBindings(); } @@ -5873,6 +6123,7 @@ public void testADLForTemplateSpecializations_327069() throws Exception { // void x(int* (*) (int*)) { // x(f); // } + @Test public void testPartialOrderingInNonCallContext_326900() throws Exception { parseAndCheckBindings(); } @@ -5885,6 +6136,7 @@ public void testPartialOrderingInNonCallContext_326900() throws Exception { // X x; // y(x); // } + @Test public void testPartialOrderingForConversions_326900() throws Exception { parseAndCheckBindings(); } @@ -5901,6 +6153,7 @@ public void testPartialOrderingForConversions_326900() throws Exception { // L::CI l; // l.m().foo = 1; // } + @Test public void testNestedTypedefSpecialization_329795() throws Exception { String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, CPP); @@ -5923,6 +6176,7 @@ public void testNestedTypedefSpecialization_329795() throws Exception { // TestImpl::Inner2* ptr2=ptr1->ptr2; // func(ptr2->ptr1); // } + @Test public void testSpecializationViaNotDirectlyEnclosingTemplate_333186() throws Exception { parseAndCheckBindings(); } @@ -5936,6 +6190,7 @@ public void testSpecializationViaNotDirectlyEnclosingTemplate_333186() throws Ex // // struct C {}; // template class Z{}; + @Test public void testNonTypeTemplateParameterWithTypenameKeyword_333186() throws Exception { parseAndCheckBindings(); } @@ -5943,6 +6198,7 @@ public void testNonTypeTemplateParameterWithTypenameKeyword_333186() throws Exce // template void f() { // f(); // } + @Test public void testDefaultTmplArgumentOfFunctionTemplate_333325() throws Exception { parseAndCheckBindings(); } @@ -5950,6 +6206,7 @@ public void testDefaultTmplArgumentOfFunctionTemplate_333325() throws Exception // template class X {}; // template void Y(); // X< Y > x; + @Test public void testFunctionInstanceAsTemplateArg_333529() throws Exception { parseAndCheckBindings(); } @@ -5976,6 +6233,7 @@ public void testFunctionInstanceAsTemplateArg_333529() throws Exception { // void test() { // P(C()); // } + @Test public void testFunctionInstanceAsTemplateArg_334472() throws Exception { parseAndCheckBindings(); } @@ -5986,6 +6244,7 @@ public void testFunctionInstanceAsTemplateArg_334472() throws Exception { // g(); // g(); // } + @Test public void testFunctionTemplateSignatures_335062() throws Exception { parseAndCheckBindings(); } @@ -6008,6 +6267,7 @@ public void testFunctionTemplateSignatures_335062() throws Exception { // void g() { // function(0); // ERROR HERE // } + @Test public void testSyntaxErrorInReturnTypeOfFunctionInstance_336426() throws Exception { parseAndCheckBindings(); } @@ -6016,6 +6276,7 @@ public void testSyntaxErrorInReturnTypeOfFunctionInstance_336426() throws Except // template void f(Functor functor) { // A a; // } + @Test public void testFunctionCallOnDependentName_337686() throws Exception { parseAndCheckBindings(); } @@ -6025,6 +6286,7 @@ public void testFunctionCallOnDependentName_337686() throws Exception { // auto* b = a->f; // b->g; // } + @Test public void testDependentNameWithAuto_407480() throws Exception { parseAndCheckBindings(); } @@ -6037,6 +6299,7 @@ public void testDependentNameWithAuto_407480() throws Exception { // h(s, 1); // h(s, 1, 2); // } + @Test public void testVariadicFunctionTemplate_333389() throws Exception { parseAndCheckBindings(); } @@ -6051,6 +6314,7 @@ public void testVariadicFunctionTemplate_333389() throws Exception { // g(v1); // g(v2); // } + @Test public void testFunctionWithVoidParamInTypeDeduction() throws Exception { parseAndCheckBindings(); } @@ -6068,6 +6332,7 @@ public void testFunctionWithVoidParamInTypeDeduction() throws Exception { // A(this, &B::m1); // } // }; + @Test public void testFunctionWithVoidParamInTypeDeduction_423127() throws Exception { parseAndCheckBindings(); } @@ -6087,6 +6352,7 @@ public void testFunctionWithVoidParamInTypeDeduction_423127() throws Exception { // int main() { // waldo(A()); // } + @Test public void testAddressOfMethodTargeted_509396() throws Exception { parseAndCheckBindings(); } @@ -6105,6 +6371,7 @@ public void testAddressOfMethodTargeted_509396() throws Exception { // void test() { // waldo(A()); // } + @Test public void testAddressOfMethodUntargeted_509396() throws Exception { parseAndCheckBindings(); } @@ -6127,6 +6394,7 @@ public void testAddressOfMethodUntargeted_509396() throws Exception { // iFive.e= 0; // return 0; // } + @Test public void testPartialSpecAfterExplicitInst_339475() throws Exception { parseAndCheckBindings(); } @@ -6144,6 +6412,7 @@ public void testPartialSpecAfterExplicitInst_339475() throws Exception { // S<1 && 2>::m(); // m is member of S // s<1 && 2>::f(); // f is global // } + @Test public void testTemplateIDAmbiguity_341747a() throws Exception { IASTTranslationUnit tu = parseAndCheckBindings(); IASTFunctionDefinition fdef = getDeclaration(tu, 4); @@ -6170,6 +6439,7 @@ public void testTemplateIDAmbiguity_341747a() throws Exception { // // template> struct T {}; // struct Y : T> {}; + @Test public void testTemplateIDAmbiguity_341747b() throws Exception { parseAndCheckBindings(); } @@ -6183,6 +6453,7 @@ public void testTemplateIDAmbiguity_341747b() throws Exception { // S< a::a; // a < S::a; // } + @Test public void testTemplateIDAmbiguity_341747c() throws Exception { parseAndCheckBindings(); } @@ -6196,6 +6467,7 @@ public void testTemplateIDAmbiguity_341747c() throws Exception { // S* a=0; // a->B::c; // } + @Test public void testTemplateIDAmbiguity_341747d() throws Exception { parseAndCheckBindings(); } @@ -6213,6 +6485,7 @@ public void testTemplateIDAmbiguity_341747d() throws Exception { // ft(&Foo::function); // return 0; // } + @Test public void testAddressOfMethodForInstantiation_344310() throws Exception { parseAndCheckBindings(); } @@ -6227,6 +6500,7 @@ public void testAddressOfMethodForInstantiation_344310() throws Exception { // int test() { // Subscribe(Callback(&CallMe)); // invalid arguments, symbol not // } + @Test public void testParameterAdjustementInInstantiatedFunctionType_351609() throws Exception { parseAndCheckBindings(); } @@ -6245,11 +6519,13 @@ public void testParameterAdjustementInInstantiatedFunctionType_351609() throws E // CT::ref; // CT::rref; // } + @Test public void testRRefVsRef_351927() throws Exception { parseAndCheckBindings(); } // template class A {}; + @Test public void testTemplateParameterWithoutName_352266() throws Exception { parseAndCheckBindings(); } @@ -6265,6 +6541,7 @@ public void testTemplateParameterWithoutName_352266() throws Exception { // typedef CTTP b; // typedef CTTP c; // typedef CTTP d; + @Test public void testTemplateTemplateParameterMatching_352859() throws Exception { parseAndCheckBindings(); } @@ -6273,6 +6550,7 @@ public void testTemplateTemplateParameterMatching_352859() throws Exception { // template<> int f() { // return 0; // } + @Test public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() throws Exception { parseAndCheckBindings(); BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); @@ -6292,6 +6570,7 @@ public void testArgumentDeductionFromReturnTypeOfExplicitSpecialization_355304() // template class B {}; // template<> class B {}; // B fooB(); + @Test public void testExplicitSpecializationOfForbiddenAsImplicit_356818() throws Exception { parseAndCheckBindings(); } @@ -6317,6 +6596,7 @@ public void testExplicitSpecializationOfForbiddenAsImplicit_356818() throws Exce // c.f(1); // c.f(1,1); // } + @Test public void testSpecializationOfUsingDeclaration_357293() throws Exception { parseAndCheckBindings(); } @@ -6324,6 +6604,7 @@ public void testSpecializationOfUsingDeclaration_357293() throws Exception { // template struct SS {}; // template > class Cont> // Cont f() {} + @Test public void testReferenceToParameterOfTemplateTemplateParameter_357308() throws Exception { parseAndCheckBindings(); } @@ -6333,6 +6614,7 @@ public void testReferenceToParameterOfTemplateTemplateParameter_357308() throws // f(); // f<>(); // } + @Test public void testTemplateArgumentDeductionWithoutParameters_358654() throws Exception { parseAndCheckBindings(); } @@ -6361,6 +6643,7 @@ public void testTemplateArgumentDeductionWithoutParameters_358654() throws Excep // void test() { // waldo([]() { return B(); }()); // } + @Test public void testTemplateArgumentDeductionWithFunctionSet_501549() throws Exception { parseAndCheckBindings(); } @@ -6384,6 +6667,7 @@ public void testTemplateArgumentDeductionWithFunctionSet_501549() throws Excepti // typedef C r; // typedef r::s t; // t::u x; + @Test public void testBoolExpressionAsTemplateArgument_361604() throws Exception { parseAndCheckBindings(); } @@ -6396,6 +6680,7 @@ public void testBoolExpressionAsTemplateArgument_361604() throws Exception { // void m(); // }; // template void C::m() {} + @Test public void testDependentUsingDeclaration() throws Exception { parseAndCheckBindings(); } @@ -6440,6 +6725,7 @@ public void testDependentUsingDeclaration() throws Exception { // ns::C::value> a; // f(a); // }; + @Test public void testDependentExpressions_a() throws Exception { parseAndCheckBindings(); } @@ -6465,6 +6751,7 @@ public void testDependentExpressions_a() throws Exception { // }; // // B::pointer a; + @Test public void testDependentExpressions_b() throws Exception { parseAndCheckBindings(); BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); @@ -6479,6 +6766,7 @@ public void testDependentExpressions_b() throws Exception { // if (T* i = foo<0>(0)) // return; // } + @Test public void testDirectlyNestedAmbiguity_362976() throws Exception { parseAndCheckBindings(); } @@ -6501,6 +6789,7 @@ public void testDirectlyNestedAmbiguity_362976() throws Exception { // int main(){ // return MaxOfN::result; // } + @Test public void testNestedTemplateAmbiguity_363609() throws Exception { parseAndCheckBindings(); } @@ -6512,6 +6801,7 @@ public void testNestedTemplateAmbiguity_363609() throws Exception { // void test() { // B b1; // } + @Test public void testDefaultArgForNonTypeTemplateParameter_363743() throws Exception { parseAndCheckBindings(); } @@ -6534,6 +6824,7 @@ public void testDefaultArgForNonTypeTemplateParameter_363743() throws Exception // delete C< a::ptr; // delete C< A::b >::ptr; // } + @Test public void testTemplateAmbiguityInDeleteExpression_364225() throws Exception { parseAndCheckBindings(); } @@ -6541,6 +6832,7 @@ public void testTemplateAmbiguityInDeleteExpression_364225() throws Exception { // template struct a {}; // const int b = 0, c = 1; // int a::*mp6; // syntax error here + @Test public void testTemplateIDAmbiguity_445177() throws Exception { parseAndCheckBindings(); } @@ -6564,6 +6856,7 @@ public void testTemplateIDAmbiguity_445177() throws Exception { // // template // using W = typename EnableIf<(I < TupleSize>::value), int>::type; + @Test public void testTemplateIDAmbiguity_497668() throws Exception { parseAndCheckBindings(); } @@ -6573,6 +6866,7 @@ public void testTemplateIDAmbiguity_497668() throws Exception { // int main() { // foo(0); // } + @Test public void testSyntaxFailureInstantiatingFunctionTemplate_365981a() throws Exception { parseAndCheckBindings(); } @@ -6582,6 +6876,7 @@ public void testSyntaxFailureInstantiatingFunctionTemplate_365981a() throws Exce // void test() { // bar(0); // } + @Test public void testSyntaxFailureInstantiatingFunctionTemplate_365981b() throws Exception { parseAndCheckBindings(); } @@ -6594,6 +6889,7 @@ public void testSyntaxFailureInstantiatingFunctionTemplate_365981b() throws Exce // } // } // }; + @Test public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception { parseAndCheckBindings(); } @@ -6611,6 +6907,7 @@ public void testResolvingAutoTypeWithDependentExpression_367472() throws Excepti // vector v; // auto x1 = begin1(v); // auto x2 = begin2(v); + @Test public void testResolvingAutoTypeWithDependentExpression_402409a() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); helper.assertVariableType("x1", CommonCPPTypes.pointerToInt); @@ -6633,6 +6930,7 @@ public void testResolvingAutoTypeWithDependentExpression_402409a() throws Except // begin1(v); // begin2(v); // } + @Test public void testResolvingAutoTypeWithDependentExpression_402409b() throws Exception { parseAndCheckBindings(); } @@ -6642,6 +6940,7 @@ public void testResolvingAutoTypeWithDependentExpression_402409b() throws Except // foo(1,2,args...); // foo(args...); // } + @Test public void testPackExpansionsAsArguments_367560() throws Exception { parseAndCheckBindings(); } @@ -6654,6 +6953,7 @@ public void testPackExpansionsAsArguments_367560() throws Exception { // int main() { // A m; // } + @Test public void testDeductionForConstFunctionType_367562() throws Exception { parseAndCheckBindings(); } @@ -6665,6 +6965,7 @@ public void testDeductionForConstFunctionType_367562() throws Exception { // template struct derived : public base { // typedef typename derived::type type; // ERROR HERE // }; + @Test public void testTemplateShortNameInQualifiedName_367607() throws Exception { parseAndCheckBindings(); BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); @@ -6678,6 +6979,7 @@ public void testTemplateShortNameInQualifiedName_367607() throws Exception { // typedef int type; // }; // typedef B >::type type; // ERROR HERE + @Test public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exception { parseAndCheckBindings(); } @@ -6688,6 +6990,7 @@ public void testPartialClassTemplateSpecUsingDefaultArgument_367997() throws Exc // template struct foo {}; // template <> struct foo<1> { typedef int type; }; // typedef foo::type t; // ERROR HERE + @Test public void testValueForSizeofExpression_368309() throws Exception { parseAndCheckBindings(); } @@ -6713,6 +7016,7 @@ public void testValueForSizeofExpression_368309() throws Exception { // auto e = *cur; // e.x; // ERROR HERE: "Field 'x' could not be resolved" // } + @Test public void testAutoTypeWithTypedef_368311() throws Exception { BindingAssertionHelper bh = new AST2AssertionHelper(getAboveComment(), CPP); IVariable v = bh.assertNonProblem("cur = r.begin()", 3); @@ -6734,6 +7038,7 @@ public void testAutoTypeWithTypedef_368311() throws Exception { // auto s = *it; // s.x; // ERROR HERE: "Field 'x' could not be resolved" // } + @Test public void testSpecializationOfClassType_368610a() throws Exception { parseAndCheckBindings(); } @@ -6752,6 +7057,7 @@ public void testSpecializationOfClassType_368610a() throws Exception { // auto s = *it; // s.x; // ERROR HERE: "Field 'x' could not be resolved" // } + @Test public void testSpecializationOfClassType_368610b() throws Exception { parseAndCheckBindings(); } @@ -6766,6 +7072,7 @@ public void testSpecializationOfClassType_368610b() throws Exception { // CT x; // x.someFunc().y; // } + @Test public void testSpecializationOfClassType_368610c() throws Exception { parseAndCheckBindings(); } @@ -6785,6 +7092,7 @@ public void testSpecializationOfClassType_368610c() throws Exception { // }; // // typedef B::result::type waldo; + @Test public void testSpecializationOfBaseClass_409078() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); ITypedef waldo = bh.assertNonProblem("waldo"); @@ -6802,6 +7110,7 @@ public void testSpecializationOfBaseClass_409078() throws Exception { // }; // // B a(&A::m); + @Test public void testConstInTypeParameter_377223() throws Exception { parseAndCheckBindings(); } @@ -6850,6 +7159,7 @@ public void testConstInTypeParameter_377223() throws Exception { // }; // // typedef A type; + @Test public void testSfinae_a() throws Exception { parseAndCheckBindings(); } @@ -6882,6 +7192,7 @@ public void testSfinae_a() throws Exception { // A::get(); // A::get(); // } + @Test public void testSfinae_b() throws Exception { parseAndCheckBindings(); } @@ -6911,6 +7222,7 @@ public void testSfinae_b() throws Exception { // int *ip = nullptr; // B b1 { ip }; // B::p jp = nullptr; + @Test public void testSfinae_c() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -6946,6 +7258,7 @@ public void testSfinae_c() throws Exception { // // int b1 = C().ccc1; // C::t b2; + @Test public void testSfinae_d() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -6974,6 +7287,7 @@ public void testSfinae_d() throws Exception { // void test() { // f(); // } + @Test public void testIsPOD_367993() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -6997,6 +7311,7 @@ public void testIsPOD_367993() throws Exception { // A a; /* no error this line */ // c.callDelegate(a); /* Invalid arguments 'Candidates are: void callDelegate(A<#0,#1> &)' */ // } + @Test public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -7007,6 +7322,7 @@ public void testDeductionOfNonTypeTemplateArg_372587() throws Exception { // void test() { // b(f); // } + @Test public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -7023,6 +7339,7 @@ public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception // C::dtm v; // f(v); // } + @Test public void testPointerToMemberAsDependentExpression_391001() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -7038,6 +7355,7 @@ public void testPointerToMemberAsDependentExpression_391001() throws Exception { // struct C {}; // // typedef C<&B::x> T; + @Test public void testPointerToMemberOfTemplateClass_402861() throws Exception { parseAndCheckBindings(); } @@ -7053,6 +7371,7 @@ public void testPointerToMemberOfTemplateClass_402861() throws Exception { // }; // // List::Base<&N::node> base; + @Test public void testDependentTemplateParameterInNestedTemplate_407497() throws Exception { parseAndCheckBindings(); } @@ -7066,6 +7385,7 @@ public void testDependentTemplateParameterInNestedTemplate_407497() throws Excep // }; // // typedef enclosing::nested<>::type waldo; + @Test public void testDependentTemplateParameterInNestedTemplate_399454() throws Exception { parseAndCheckBindings(); } @@ -7081,6 +7401,7 @@ public void testDependentTemplateParameterInNestedTemplate_399454() throws Excep // Container<&memory>::iterator it; // it.test; // Field 'test' could not be resolved // } + @Test public void testAddressAsTemplateArgument_391190() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -7091,6 +7412,7 @@ public void testAddressAsTemplateArgument_391190() throws Exception { // void test(int off) { // off < CT::const_min || off > CT::const_min; // } + @Test public void testTemplateIDAmbiguity_393959() throws Exception { parseAndCheckBindings(getAboveComment(), CPP, ScannerKind.GNU); } @@ -7101,6 +7423,7 @@ public void testTemplateIDAmbiguity_393959() throws Exception { // Alias x; // } // }; + @Test public void testNestedAliasDeclarationNestingLevel() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -7122,6 +7445,7 @@ public void testNestedAliasDeclarationNestingLevel() throws Exception { // template class CT { // nesting level 0 // typedef Alias TYPE; // }; + @Test public void testAliasDeclarationNestingLevel() throws Exception { final String code = getAboveComment(); BindingAssertionHelper bh = new AST2AssertionHelper(code, true); @@ -7145,6 +7469,7 @@ public void testAliasDeclarationNestingLevel() throws Exception { // Alias myA; // myA.x = 42; // } + @Test public void testSimpleAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7173,6 +7498,7 @@ public void testSimpleAliasDeclaration() throws Exception { // Alias myA; // myA.x = 42; // } + @Test public void testSpecifiedTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7197,6 +7523,7 @@ public void testSpecifiedTemplateAliasDeclaration() throws Exception { // Alias myA; // myA = 42; // } + @Test public void testTemplatedAliasBasicType() throws Exception { parseAndCheckBindings(); @@ -7222,6 +7549,7 @@ public void testTemplatedAliasBasicType() throws Exception { // TAlias myA; // myA.t = 42; // } + @Test public void testTemplatedAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7263,6 +7591,7 @@ public void testTemplatedAliasDeclaration() throws Exception { // myA.t2 = 42.0f; // myA.t3 = true; // } + @Test public void testTemplatedAliasDeclarationMultipleParameters() throws Exception { parseAndCheckBindings(); @@ -7314,6 +7643,7 @@ public void testTemplatedAliasDeclarationMultipleParameters() throws Exception { // TAlias> myA; // myA.t = S(); // } + @Test public void testTemplatedAliasDeclarationTemplateArgument() throws Exception { parseAndCheckBindings(); @@ -7338,6 +7668,7 @@ public void testTemplatedAliasDeclarationTemplateArgument() throws Exception { // S> myA; // myA.t = S(); // } + @Test public void testTemplatedAliasAsTemplateArgument() throws Exception { parseAndCheckBindings(); @@ -7362,6 +7693,7 @@ public void testTemplatedAliasAsTemplateArgument() throws Exception { // TAlias<5, 4> myA; // myA.buff[0] = 1; // } + @Test public void testTemplatedAliasDeclarationValueArgument() throws Exception { parseAndCheckBindings(); @@ -7386,6 +7718,7 @@ public void testTemplatedAliasDeclarationValueArgument() throws Exception { // TAlias<> myA; // myA.buff[0] = 1; // } + @Test public void testTemplatedAliasDefaultArguments() throws Exception { parseAndCheckBindings(); @@ -7413,6 +7746,7 @@ public void testTemplatedAliasDefaultArguments() throws Exception { // TAlias myA; // myA.t = S(); // } + @Test public void testTemplatedAliasTemplateArgument() throws Exception { parseAndCheckBindings(); @@ -7441,6 +7775,7 @@ public void testTemplatedAliasTemplateArgument() throws Exception { // S myS; // bar(myS); // } + @Test public void testTemplatedAliasAsFunctionParameter() throws Exception { parseAndCheckBindings(); @@ -7466,6 +7801,7 @@ public void testTemplatedAliasAsFunctionParameter() throws Exception { // TAlias myA; // bar(myA); // } + @Test public void testTemplatedAliasAsFunctionArgument() throws Exception { parseAndCheckBindings(); @@ -7487,6 +7823,7 @@ public void testTemplatedAliasAsFunctionArgument() throws Exception { // } // void bar(TAlias arg){ // } + @Test public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("bar(S", "bar", ICPPFunction.class); @@ -7505,6 +7842,7 @@ public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception { // g(v); // f(v); // } + @Test public void testTemplatedAliasDeduction() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertNonProblem("g(v)", "g", ICPPFunction.class); @@ -7515,6 +7853,7 @@ public void testTemplatedAliasDeduction() throws Exception { // void foo(int) { // function f = &foo; // } + @Test public void testSimpleFunctionAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7541,6 +7880,7 @@ public void testSimpleFunctionAliasDeclaration() throws Exception { // TAlias myA = myS; // myA.t = 42; // } + @Test public void testTemplatedAliasForTemplateReference() throws Exception { parseAndCheckBindings(); @@ -7559,6 +7899,7 @@ public void testTemplatedAliasForTemplateReference() throws Exception { // void foo(int) { // function f = &foo; // } + @Test public void testSimpleFunctionTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7581,6 +7922,7 @@ public void testSimpleFunctionTemplateAliasDeclaration() throws Exception { // void foo(int) { // function f = &foo; // } + @Test public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception { parseAndCheckBindings(); @@ -7608,6 +7950,7 @@ public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Excepti // TAlias > myA; // myA.t = S(); // } + @Test public void testTemplatedAliasTemplateParameter() throws Exception { parseAndCheckBindings(); @@ -7643,6 +7986,7 @@ public void testTemplatedAliasTemplateParameter() throws Exception { // void test() { // B::Waldo<&D::m>(); // } + @Test public void testTemplatedAliasWithPointerToMember_448785() throws Exception { parseAndCheckBindings(); } @@ -7657,6 +8001,7 @@ public void testTemplatedAliasWithPointerToMember_448785() throws Exception { // } // using namespace NS; // Alias intAlias; + @Test public void testAliasDeclarationContext() throws Exception { parseAndCheckBindings(); @@ -7720,6 +8065,7 @@ public void testAliasDeclarationContext() throws Exception { // void test(E>::type v) { // f(v); // } + @Test public void testAliasTemplate_395026a() throws Exception { parseAndCheckBindings(); } @@ -7765,6 +8111,7 @@ public void testAliasTemplate_395026a() throws Exception { // E v; // f(*v[0]); // } + @Test public void testAliasTemplate_395026b() throws Exception { parseAndCheckBindings(); } @@ -7781,6 +8128,7 @@ public void testAliasTemplate_395026b() throws Exception { // void test(A* c) { // f(c); // } + @Test public void testAliasTemplate_416280_1() throws Exception { parseAndCheckBindings(); } @@ -7797,6 +8145,7 @@ public void testAliasTemplate_416280_1() throws Exception { // struct D : public A { // B b; // }; + @Test public void testAliasTemplate_416280_2() throws Exception { parseAndCheckBindings(); } @@ -7817,6 +8166,7 @@ public void testAliasTemplate_416280_2() throws Exception { // }; // // bool b = D::template AD::val; + @Test public void testAliasTemplate_486618() throws Exception { parseAndCheckBindings(); } @@ -7855,6 +8205,7 @@ public void testAliasTemplate_486618() throws Exception { // waldo3(two, one); // waldo4(two, two); // } + @Test public void testAliasTemplate_486971() throws Exception { parseAndCheckBindings(); } @@ -7914,6 +8265,7 @@ public void testAliasTemplate_486971() throws Exception { // C a; // waldo(a); // } + @Test public void testAliasTemplate_502109() throws Exception { parseAndCheckBindings(); } @@ -7928,6 +8280,7 @@ public void testAliasTemplate_502109() throws Exception { // int main() { // waldo(Alias()); // } + @Test public void testTemplateIdNamingAliasTemplateInExpression_472615() throws Exception { parseAndCheckBindings(); } @@ -7942,6 +8295,7 @@ public void testTemplateIdNamingAliasTemplateInExpression_472615() throws Except // typedef typename Traits::template rebind type; // }; // typedef Meta::type Waldo; + @Test public void testNestedAliasTemplate_488456() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ITypedef waldo = helper.assertNonProblem("Waldo"); @@ -8013,6 +8367,7 @@ public void testNestedAliasTemplate_488456() throws Exception { // F a; // f(*a[0]); // } + @Test public void testConstexprFunction_395238a() throws Exception { parseAndCheckBindings(); } @@ -8042,6 +8397,7 @@ public void testConstexprFunction_395238a() throws Exception { // // B::type x; // B::type y; + @Test public void testConstexprFunction_395238b() throws Exception { BindingAssertionHelper ah = getAssertionHelper(); ITypedef td = ah.assertNonProblem("B::type", "type", ITypedef.class); @@ -8059,6 +8415,7 @@ public void testConstexprFunction_395238b() throws Exception { // void bar() { // A::g(); // } + @Test public void testConstexprFunctionCallInTemplateArgument_332829() throws Exception { parseAndCheckBindings(); } @@ -8071,6 +8428,7 @@ public void testConstexprFunctionCallInTemplateArgument_332829() throws Exceptio // struct Waldo {}; // // Waldo w; // Syntax error + @Test public void testUniformInitializationInTemplateArgument_510010() throws Exception { parseAndCheckBindings(); } @@ -8081,6 +8439,7 @@ public void testUniformInitializationInTemplateArgument_510010() throws Exceptio // ++i; // } // } + @Test public void testRegression_510010() throws Exception { parseAndCheckBindings(); } @@ -8110,6 +8469,7 @@ public void testRegression_510010() throws Exception { // void test(int x) { // waldo(x); // } + @Test public void testConstexprMethod_489987() throws Exception { parseAndCheckBindings(); } @@ -8126,6 +8486,7 @@ public void testConstexprMethod_489987() throws Exception { // }; // struct Cat {}; // typedef S::value>::type T; + @Test public void testDependentExpressionInvolvingField_388623() throws Exception { parseAndCheckBindings(); } @@ -8138,6 +8499,7 @@ public void testDependentExpressionInvolvingField_388623() throws Exception { // int main() { // foo(S()); // } + @Test public void testSfinaeInDefaultArgument() throws Exception { parseAndCheckBindings(); } @@ -8164,6 +8526,7 @@ public void testSfinaeInDefaultArgument() throws Exception { // // constexpr int value_via_adl = f(E1); // ADL via enumeration argument finds is_augmented(E*) // constexpr int value_no_adl = g(int(E1)); // Error: no ADL performed, is_augmented(int*) is not found + @Test public void testSfinaeInDependentContext() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); bh.assertVariableValue("value_via_adl", 42); @@ -8187,6 +8550,7 @@ public void testSfinaeInDependentContext() throws Exception { // }; // // const bool B = has_type::value; + @Test public void testSfinaeInNestedTypeInTemplateArgument_402257() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); ICPPVariable B = helper.assertNonProblem("B"); @@ -8214,6 +8578,7 @@ public void testSfinaeInNestedTypeInTemplateArgument_402257() throws Exception { // S waldo; // A() : waldo(B{}) {} // }; + @Test public void testSfinaeInTemplatedConversionOperator_409056() throws Exception { parseAndCheckImplicitNameBindings(); } @@ -8238,6 +8603,7 @@ public void testSfinaeInTemplatedConversionOperator_409056() throws Exception { // typename enable_if::value>::type waldo(); // // auto x = waldo; + @Test public void testSfinaeWhenResolvingAddressOfFunction_429928() throws Exception { parseAndCheckBindings(); } @@ -8260,6 +8626,7 @@ public void testSfinaeWhenResolvingAddressOfFunction_429928() throws Exception { // typename enable_if::value>::type waldo(); // // auto x = waldo; + @Test public void testSfinaeInNonTypeTemplateParameter_429928() throws Exception { parseAndCheckBindings(); } @@ -8275,6 +8642,7 @@ public void testSfinaeInNonTypeTemplateParameter_429928() throws Exception { // int waldo(int p); // // int x = waldo(test(0)); + @Test public void testSfinaeInConstructorCall_430230() throws Exception { parseAndCheckBindings(); } @@ -8290,6 +8658,7 @@ public void testSfinaeInConstructorCall_430230() throws Exception { // int waldo(int p); // // int x = waldo(test(0)); + @Test public void testSfinaeInNewExpression_430230a() throws Exception { parseAndCheckBindings(); } @@ -8340,6 +8709,7 @@ public void testSfinaeInNewExpression_430230a() throws Exception { // waldo(); // // auto x = waldo; + @Test public void testSfinaeInNewExpression_430230b() throws Exception { parseAndCheckBindings(); } @@ -8357,6 +8727,7 @@ public void testSfinaeInNewExpression_430230b() throws Exception { // int waldo(int p); // // int x = waldo(test(0)); + @Test public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exception { parseAndCheckBindings(); } @@ -8382,6 +8753,7 @@ public void testSfinaeInNewExpressionWithDeletedConstructor_430230() throws Exce // void test() { // waldo(""); // } + @Test public void testSfinaeInIdExpression_459940() throws Exception { parseAndCheckBindings(); } @@ -8395,6 +8767,7 @@ public void testSfinaeInIdExpression_459940() throws Exception { // void test() { // waldo(1); // } + @Test public void testSfinaeInTrailingReturnType_495845() throws Exception { parseAndCheckBindings(); } @@ -8432,6 +8805,7 @@ public void testSfinaeInTrailingReturnType_495845() throws Exception { // void test() { // waldo(1); // } + @Test public void testSfinaeInTrailingReturnType_495952() throws Exception { parseAndCheckBindings(); } @@ -8444,6 +8818,7 @@ public void testSfinaeInTrailingReturnType_495952() throws Exception { // void foo() { // new M((int*)0, 0); // } + @Test public void testVariadicConstructor_395247() throws Exception { parseAndCheckBindings(); } @@ -8461,6 +8836,7 @@ public void testVariadicConstructor_395247() throws Exception { // static const int value = sizeof(waldo(f)); // }; // typedef identity::value>>::type reference; + @Test public void testDependentExpressions_395243a() throws Exception { parseAndCheckBindings(); } @@ -8489,6 +8865,7 @@ public void testDependentExpressions_395243a() throws Exception { // typedef int foo_type; // }; // traits::value>::bar_type a; + @Test public void testDependentExpressions_395243b() throws Exception { parseAndCheckBindings(); } @@ -8507,6 +8884,7 @@ public void testDependentExpressions_395243b() throws Exception { // for (auto s : v.arr) // s.foo(); // } + @Test public void testDependentExpressions_395243c() throws Exception { parseAndCheckBindings(); } @@ -8524,6 +8902,7 @@ public void testDependentExpressions_395243c() throws Exception { // x->m(); // } // }; + @Test public void testDependentExpressions_395243d() throws Exception { parseAndCheckBindings(); } @@ -8541,6 +8920,7 @@ public void testDependentExpressions_395243d() throws Exception { // void test() { // int x = C::id; // } + @Test public void testDependentEnumValue_389009() throws Exception { BindingAssertionHelper ah = getAssertionHelper(); IEnumerator binding = ah.assertNonProblem("C::id", "id"); @@ -8579,6 +8959,7 @@ public void testDependentEnumValue_389009() throws Exception { // void bar(B& v) { // v.waldo(); // } + @Test public void testArgumentDependentLookupForEnumeration_506170() throws Exception { parseAndCheckBindings(); } @@ -8588,6 +8969,7 @@ public void testArgumentDependentLookupForEnumeration_506170() throws Exception // int main() { // foo(A<0>()); // } + @Test public void testVariadicNonTypeTemplateParameter_382074() throws Exception { parseAndCheckBindings(); } @@ -8615,6 +8997,7 @@ public void testVariadicNonTypeTemplateParameter_382074() throws Exception { // meta::value>::type t; // t.bar(); // } + @Test public void testVariadicNonTypeTemplateParameter_399039() throws Exception { parseAndCheckBindings(); } @@ -8630,6 +9013,7 @@ public void testVariadicNonTypeTemplateParameter_399039() throws Exception { // typedef int type; // }; // typedef common_type::type type; + @Test public void testClassTemplateSpecializationPartialOrdering_398044a() throws Exception { parseAndCheckBindings(); } @@ -8645,6 +9029,7 @@ public void testClassTemplateSpecializationPartialOrdering_398044a() throws Exce // int main() { // A mf; // } + @Test public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exception { parseAndCheckBindings(); } @@ -8658,6 +9043,7 @@ public void testClassTemplateSpecializationPartialOrdering_398044b() throws Exce // struct waldo; // // typedef waldo::type Type; + @Test public void testPartialSpecializationForVarargFunctionType_402807() throws Exception { parseAndCheckBindings(); } @@ -8671,6 +9057,7 @@ public void testPartialSpecializationForVarargFunctionType_402807() throws Excep // struct waldo; // // typedef waldo::type Type; + @Test public void testPartialSpecializationForRefQualifiedFunctionType_485888() throws Exception { parseAndCheckBindings(); } @@ -8692,6 +9079,7 @@ public void testPartialSpecializationForRefQualifiedFunctionType_485888() throws // using ActualType = term_traits::value_type; // // using ExpectedType = char[4]; + @Test public void testQualifierTypeThatCollapsesAfterTypedefSubstitution_487698() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ITypedef actualType = helper.assertNonProblem("ActualType"); @@ -8719,6 +9107,7 @@ public void testQualifierTypeThatCollapsesAfterTypedefSubstitution_487698() thro // void test() { // push_back(0); // } + @Test public void testRegression_399142() throws Exception { parseAndCheckBindings(); } @@ -8735,6 +9124,7 @@ public void testRegression_399142() throws Exception { // int main() { // W::value>::type w; // } + @Test public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws Exception { parseAndCheckBindings(); } @@ -8753,6 +9143,7 @@ public void testDependentExpressionInvolvingFieldInNestedClass_399362() throws E // }; // // typedef decltype(W()()) waldo; + @Test public void testInstantiationOfConstMemberAccess_409107() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); IType waldo = bh.assertNonProblem("waldo"); @@ -8794,6 +9185,7 @@ public void testInstantiationOfConstMemberAccess_409107() throws Exception { // int main() { // S::value>::type t; // } + @Test public void testVariadicTemplates_401024() throws Exception { parseAndCheckBindings(); } @@ -8811,6 +9203,7 @@ public void testVariadicTemplates_401024() throws Exception { // S s; // bar(foo(s(0))); // } + @Test public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception { parseAndCheckBindings(); } @@ -8846,6 +9239,7 @@ public void testVariadicTemplatesAndFunctionObjects_401479() throws Exception { // void test() { // waldo(""); // } + @Test public void testPackExpansionInNestedTemplate_459844() throws Exception { parseAndCheckBindings(); } @@ -8857,6 +9251,7 @@ public void testPackExpansionInNestedTemplate_459844() throws Exception { // struct C : A... {}; // // constexpr bool answer = __is_base_of(A, C); + @Test public void testPackExpansionInBaseSpecifier_487703() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable answer = helper.assertNonProblem("answer"); @@ -8870,6 +9265,7 @@ public void testPackExpansionInBaseSpecifier_487703() throws Exception { // struct SpecificMixin {}; // // constexpr bool answer = __is_base_of(SpecificMixin, C); + @Test public void testTemplateTemplateParameterPack_487703a() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable answer = helper.assertNonProblem("answer"); @@ -8884,6 +9280,7 @@ public void testTemplateTemplateParameterPack_487703a() throws Exception { // // typedef C Waldo; // constexpr bool answer = __is_base_of(SpecificMixin, Waldo); + @Test public void testTemplateTemplateParameterPack_487703b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable answer = helper.assertNonProblem("answer"); @@ -8906,6 +9303,7 @@ public void testTemplateTemplateParameterPack_487703b() throws Exception { // N::impl::type operand; // operand.kind(); // } + @Test public void testNameLookupInDependentExpression_399829a() throws Exception { parseAndCheckBindings(); } @@ -8930,6 +9328,7 @@ public void testNameLookupInDependentExpression_399829a() throws Exception { // N::impl::type operand; // operand.kind(); // } + @Test public void testNameLookupInDependentExpression_399829b() throws Exception { parseAndCheckBindings(); } @@ -8953,6 +9352,7 @@ public void testNameLookupInDependentExpression_399829b() throws Exception { // S operator==(T, T*); // template // S<(is_int::value)> operator==(T, T); + @Test public void testRegression_399829() throws Exception { parseAndCheckBindings(); } @@ -8968,6 +9368,7 @@ public void testRegression_399829() throws Exception { // S s; // auto waldo = bar(&s); // } + @Test public void testDependentFieldReference_472436a() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableType("waldo", CommonCPPTypes.int_); @@ -8987,6 +9388,7 @@ public void testDependentFieldReference_472436a() throws Exception { // S s; // auto waldo = bar(&s); // } + @Test public void testDependentFieldReference_472436b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableType("waldo", CommonCPPTypes.int_); @@ -9009,6 +9411,7 @@ public void testDependentFieldReference_472436b() throws Exception { // S s; // bind(s, 0, foo); // } + @Test public void testNPE_401140() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); helper.assertProblem("bind(s, 0, foo)", "bind"); @@ -9028,6 +9431,7 @@ public void testNPE_401140() throws Exception { // int foo(void*, S* = 0); // // int value = sizeof(foo(0)); + @Test public void testNPE_395074() throws Exception { parseAndCheckBindings(); } @@ -9038,6 +9442,7 @@ public void testNPE_395074() throws Exception { // int combine(S1&& r1, S2&& r2); // template // auto combine(S1 r1, S2 r2) -> decltype(combine(forward(r1), forward(r2))); + @Test public void testUnsupportedOperationExceptionInASTAmbiguousNode_402085() throws Exception { parseAndCheckBindings(); } @@ -9057,6 +9462,7 @@ public void testUnsupportedOperationExceptionInASTAmbiguousNode_402085() throws // int main() { // S::value>::type t; // } + @Test public void testVariadicNonTypeTemplateParameter_401142() throws Exception { parseAndCheckBindings(); } @@ -9079,6 +9485,7 @@ public void testVariadicNonTypeTemplateParameter_401142() throws Exception { // int main() { // S::value>::type t; // } + @Test public void testVariadicNonTypeTemplateParameter_401400() throws Exception { parseAndCheckBindings(); } @@ -9088,6 +9495,7 @@ public void testVariadicNonTypeTemplateParameter_401400() throws Exception { // static constexpr int i = sizeof...(Args); // }; // constexpr int bar = foo::i; + @Test public void testSizeofParameterPackOnTypeid_401973() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); ICPPVariable bar = helper.assertNonProblem("bar"); @@ -9115,6 +9523,7 @@ public void testSizeofParameterPackOnTypeid_401973() throws Exception { // typedef typename make_tuple_indices<1 + sizeof...(Args), 1>::type Index; // } // }; + @Test public void testVariadicTemplatesNPE_401743() throws Exception { parseAndCheckBindings(); } @@ -9131,6 +9540,7 @@ public void testVariadicTemplatesNPE_401743() throws Exception { // S<> s; // s.waldo(0, 0); // ERROR HERE // } + @Test public void testParameterPackInNestedTemplate_441028() throws Exception { parseAndCheckBindings(); } @@ -9153,6 +9563,7 @@ public void testParameterPackInNestedTemplate_441028() throws Exception { // }; // // prober, 0>::t>::t g(); + @Test public void testParameterPack_485806() throws Exception { parseAndCheckBindings(); } @@ -9163,6 +9574,7 @@ public void testParameterPack_485806() throws Exception { // int main() { // waldo(); // } + @Test public void testExplicitArgumentsForParameterPack_404245() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertProblem("waldo()", "waldo"); @@ -9180,6 +9592,7 @@ public void testExplicitArgumentsForParameterPack_404245() throws Exception { // void foo2(A... t) { // bar(t.waldo...); // } + @Test public void testMemberAccessInPackExpansion_442213() throws Exception { parseAndCheckBindings(); } @@ -9208,6 +9621,7 @@ public void testMemberAccessInPackExpansion_442213() throws Exception { // void foo1(const T&... t) { // bar(t.waldo...); // } + @Test public void testMemberAccessViaReferenceInPackExpansion_466845() throws Exception { parseAndCheckBindings(); } @@ -9230,6 +9644,7 @@ public void testMemberAccessViaReferenceInPackExpansion_466845() throws Exceptio // A a; // waldo(a, C<>()); // } + @Test public void testDecltypeInPackExpansion_486425a() throws Exception { parseAndCheckBindings(); } @@ -9252,6 +9667,7 @@ public void testDecltypeInPackExpansion_486425a() throws Exception { // A a; // waldo(a, C<>()); // } + @Test public void testDecltypeInPackExpansion_486425b() throws Exception { parseAndCheckBindings(); } @@ -9266,6 +9682,7 @@ public void testDecltypeInPackExpansion_486425b() throws Exception { // decltype(__declval()) declval(); // // using T = decltype(declval()); + @Test public void testDeclvalDeclaration_540957() throws Exception { parseAndCheckBindings(); } @@ -9284,6 +9701,7 @@ public void testDeclvalDeclaration_540957() throws Exception { // int main() { // async(); // ERROR: Invalid arguments // } + @Test public void testDependentPackExpansionInFunctionType_526684() throws Exception { parseAndCheckBindings(); } @@ -9300,6 +9718,7 @@ public void testDependentPackExpansionInFunctionType_526684() throws Exception { // }; // // typedef tuple_element::type Waldo; + @Test public void testSizeofParameterPack_527697() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ITypedef waldo = helper.assertNonProblem("Waldo"); @@ -9324,6 +9743,7 @@ public void testSizeofParameterPack_527697() throws Exception { // int main() { // function<0>(); // } + @Test public void testSizeofParameterPack_574196() throws Exception { parseAndCheckBindings(); } @@ -9346,6 +9766,7 @@ public void testSizeofParameterPack_574196() throws Exception { // int main() { // function<0>(); // } + @Test public void testSizeofParameterPack_574196_2() throws Exception { parseAndCheckBindings(); } @@ -9368,6 +9789,7 @@ public void testSizeofParameterPack_574196_2() throws Exception { // int main() { // function<0>(); // } + @Test public void testSizeofParameterPack_574196_3() throws Exception { parseAndCheckBindings(); } @@ -9390,6 +9812,7 @@ public void testSizeofParameterPack_574196_3() throws Exception { // int main() { // function<0>(); // } + @Test public void testSizeofParameterPack_574196_4() throws Exception { parseAndCheckBindings(); } @@ -9435,6 +9858,7 @@ public void testSizeofParameterPack_574196_4() throws Exception { // int main() { // function<1234>(); // } + @Test public void testSizeofParameterPack_574196_6() throws Exception { parseAndCheckBindings(); } @@ -9451,6 +9875,7 @@ public void testSizeofParameterPack_574196_6() throws Exception { // B b; // waldo(b); // } + @Test public void testTemplateArgumentDeduction_MultipleInheritance_527697() throws Exception { parseAndCheckBindings(); } @@ -9471,6 +9896,7 @@ public void testTemplateArgumentDeduction_MultipleInheritance_527697() throws Ex // typedef A> D; // // typedef B::type E; + @Test public void testRegression_401743a() throws Exception { parseAndCheckBindings(); } @@ -9493,6 +9919,7 @@ public void testRegression_401743a() throws Exception { // typedef A> D; // // typedef B::type E; + @Test public void testRegression_401743b() throws Exception { parseAndCheckBindings(); } @@ -9516,6 +9943,7 @@ public void testRegression_401743b() throws Exception { // C::pointer p; // p->a = 0; // } + @Test public void testPseudoRecursiveTypedef_408314() throws Exception { CPPASTNameBase.sAllowRecursionBindings = true; parseAndCheckBindings(); @@ -9525,6 +9953,7 @@ public void testPseudoRecursiveTypedef_408314() throws Exception { // void foo(T t) { // bar(t); // } + @Test public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception { parseAndCheckBindings(); } @@ -9540,6 +9969,7 @@ public void testUnqualifiedFunctionCallInTemplate_402498a() throws Exception { // int main() { // auto x = foo(N::A()); // } + @Test public void testUnqualifiedFunctionCallInTemplate_402498b() throws Exception { new AST2AssertionHelper(getAboveComment(), true).assertVariableType("x", CommonCPPTypes.int_); } @@ -9556,6 +9986,7 @@ public void testUnqualifiedFunctionCallInTemplate_402498b() throws Exception { // int main() { // auto x = foo(N::A()); // } + @Test public void testUnqualifiedFunctionCallInTemplate_402498c() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); ICPPVariable x = helper.assertNonProblem("x"); @@ -9585,6 +10016,7 @@ public void testUnqualifiedFunctionCallInTemplate_402498c() throws Exception { // auto x = foo(N::A()); // x.woof(); // } + @Test public void testUnqualifiedFunctionCallInTemplate_402498d() throws Exception { parseAndCheckBindings(); } @@ -9595,6 +10027,7 @@ public void testUnqualifiedFunctionCallInTemplate_402498d() throws Exception { // void foo(T t) { // bar(t); // } + @Test public void testUnqualifiedFunctionCallInTemplate_458316a() throws Exception { parseAndCheckBindings(); } @@ -9615,6 +10048,7 @@ public void testUnqualifiedFunctionCallInTemplate_458316a() throws Exception { // int main() { // foo(N::S()).meow(); // } + @Test public void testUnqualifiedFunctionCallInTemplate_458316b() throws Exception { parseAndCheckBindings(); } @@ -9635,6 +10069,7 @@ public void testUnqualifiedFunctionCallInTemplate_458316b() throws Exception { // // A a; // auto b = foo(a); + @Test public void testQualifiedNameLookupInTemplate_402854() throws Exception { BindingAssertionHelper helper = new AST2AssertionHelper(getAboveComment(), true); helper.assertVariableType("b", CommonCPPTypes.int_); @@ -9647,6 +10082,7 @@ public void testQualifiedNameLookupInTemplate_402854() throws Exception { // struct B : public A { // B(int c) : A(c) {} // }; + @Test public void testTemplateBaseClassConstructorCall_402602() throws Exception { parseAndCheckBindings(); } @@ -9661,6 +10097,7 @@ public void testTemplateBaseClassConstructorCall_402602() throws Exception { // private: // int privateMemberVariable; // }; + @Test public void testTemplateMemberAccessibility() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -9692,6 +10129,7 @@ public void testTemplateMemberAccessibility() throws Exception { // private: // int specializedPrivateVariable; // }; + @Test public void testTemplateSpecializationMemberAccessibility() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -9727,6 +10165,7 @@ public void testTemplateSpecializationMemberAccessibility() throws Exception { // a->protectedMemberVariable = 0; // a->privateMemberVariable = 0; // } + @Test public void testInstanceMemberAccessibility() throws Exception { BindingAssertionHelper bh = getAssertionHelper(); @@ -9776,6 +10215,7 @@ public void testInstanceMemberAccessibility() throws Exception { // int main() { // foo(); // } + @Test public void testInstantiationOfTypedef_412555() throws Exception { parseAndCheckBindings(); } @@ -9793,6 +10233,7 @@ public void testInstantiationOfTypedef_412555() throws Exception { // // template // void A, T>::method() {} + @Test public void testOutOfLineMethodOfPartialSpecialization_401152() throws Exception { parseAndCheckBindings(); } @@ -9812,6 +10253,7 @@ public void testOutOfLineMethodOfPartialSpecialization_401152() throws Exception // int main() { // U::type x; // } + @Test public void testDependentDecltypeInNameQualifier_415198() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertNonProblem("decltype(foo(T()))::type"); @@ -9828,6 +10270,7 @@ public void testDependentDecltypeInNameQualifier_415198() throws Exception { // }; // // decltype(B::c)::type x; + @Test public void testDependentDecltypeInNameQualifier_429837() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); assertSameType((ITypedef) helper.assertNonProblem("decltype(B::c)::type"), CommonCPPTypes.int_); @@ -9849,6 +10292,7 @@ public void testDependentDecltypeInNameQualifier_429837() throws Exception { // template // void C::waldo() {} // } + @Test public void testMemberOfPartialSpecialization_416788() throws Exception { parseAndCheckBindings(); } @@ -9874,6 +10318,7 @@ public void testMemberOfPartialSpecialization_416788() throws Exception { // myObject.method<0>(); // return 0; // } + @Test public void testSpecializedEnumerator_418770() throws Exception { parseAndCheckBindings(); } @@ -9890,6 +10335,7 @@ public void testSpecializedEnumerator_418770() throws Exception { // class A { // friend int ns::waldo(const A&); // }; + @Test public void testDependentSpecializationOfFunctionTemplateAsFriend_422505a() throws Exception { parseAndCheckBindings(); } @@ -9904,6 +10350,7 @@ public void testDependentSpecializationOfFunctionTemplateAsFriend_422505a() thro // class A { // friend int waldo(const A&); // }; + @Test public void testDependentSpecializationOfFunctionTemplateAsFriend_422505b() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertNonProblem("waldo", ICPPDeferredFunction.class); @@ -9931,6 +10378,7 @@ public void testDependentSpecializationOfFunctionTemplateAsFriend_422505b() thro // A a; // waldo(a); // } + @Test public void testDependentFunctionSet_485985() throws Exception { parseAndCheckBindings(); } @@ -9954,6 +10402,7 @@ public void testDependentFunctionSet_485985() throws Exception { // void test() { // waldo(0); // } + @Test public void testDependentConversionOperator_486149() throws Exception { parseAndCheckBindings(); } @@ -9968,6 +10417,7 @@ public void testDependentConversionOperator_486149() throws Exception { // }; // // constexpr bool waldo = negate(boolean()); + @Test public void testDependentConversionOperator_486426() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPVariable waldo = helper.assertNonProblem("waldo"); @@ -9986,6 +10436,7 @@ public void testDependentConversionOperator_486426() throws Exception { // }; // // constexpr int waldo = S::b; + @Test public void testDependentConditionalExpression_506170() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); helper.assertVariableValue("waldo", 42); @@ -10004,6 +10455,7 @@ public void testDependentConditionalExpression_506170() throws Exception { // C x; // waldo(x, x); // } + @Test public void testStrayFriends_419301() throws Exception { parseAndCheckBindings(); } @@ -10025,6 +10477,7 @@ public void testStrayFriends_419301() throws Exception { // void test() { // waldo(foo(c, d)); // } + @Test public void testInstantiationOfFriendOfNestedClassInsideTemplate_484162() throws Exception { parseAndCheckBindings(); } @@ -10040,6 +10493,7 @@ public void testInstantiationOfFriendOfNestedClassInsideTemplate_484162() throws // } // // constexpr unsigned waldo = t(0u); + @Test public void testSpecializationOfConstexprFunction_420995() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); ICPPVariable waldo = helper.assertNonProblem("waldo"); @@ -10065,6 +10519,7 @@ public void testSpecializationOfConstexprFunction_420995() throws Exception { // } // // }; + @Test public void testConstexprFunctionCallWithNonConstexprArguments_429891() throws Exception { parseAndCheckBindings(); } @@ -10083,6 +10538,7 @@ public void testConstexprFunctionCallWithNonConstexprArguments_429891() throws E // } // // constexpr int waldo = foo(); + @Test public void testInstantiationOfReturnExpression_484959() throws Exception { getAssertionHelper().assertVariableValue("waldo", 42); } @@ -10105,6 +10561,7 @@ public void testInstantiationOfReturnExpression_484959() throws Exception { // template // struct C3 { typedef B type; }; // C3<>::type c3; + @Test public void testNameLookupInDefaultTemplateArgument_399145() throws Exception { parseAndCheckBindings(); } @@ -10133,6 +10590,7 @@ public void testNameLookupInDefaultTemplateArgument_399145() throws Exception { // g(a); // } // } + @Test public void testLocalTypeAsTemplateArgument_442832() throws Exception { parseAndCheckBindings(); } @@ -10154,6 +10612,7 @@ public void testLocalTypeAsTemplateArgument_442832() throws Exception { // Bar var1; // auto var2 = foo(S()); // } + @Test public void testTypeOfUnknownMember_447728() throws Exception { BindingAssertionHelper helper = getAssertionHelper(); IVariable var1 = helper.assertNonProblem("var1"); @@ -10166,6 +10625,7 @@ public void testTypeOfUnknownMember_447728() throws Exception { // typedef decltype(T::member) C; // typedef decltype(C::member) D; // } + @Test public void testScopeOfUnkownMemberType_525982() throws Exception { parseAndCheckBindings(); } @@ -10200,6 +10660,7 @@ public void testScopeOfUnkownMemberType_525982() throws Exception { // S s; // s.waldo = 42; // } + @Test public void testClassSpecializationInEnumerator_457511() throws Exception { parseAndCheckBindings(); } @@ -10212,6 +10673,7 @@ public void testClassSpecializationInEnumerator_457511() throws Exception { // // using type = TypeTemplate>; // }; + @Test public void testAmbiguityResolutionOrder_462348a() throws Exception { parseAndCheckBindings(); } @@ -10226,6 +10688,7 @@ public void testAmbiguityResolutionOrder_462348a() throws Exception { // using type = TypeTemplate>; // }; // }; + @Test public void testAmbiguityResolutionOrder_462348b() throws Exception { parseAndCheckBindings(); } @@ -10277,6 +10740,7 @@ public void testAmbiguityResolutionOrder_462348b() throws Exception { // B b; // b.method(); // } + @Test public void testAmbiguityResolution_469788() throws Exception { parseAndCheckBindings(); } @@ -10302,6 +10766,7 @@ public void _testAmbiguityResolution_497931() throws Exception { // template // static S waldo(int); // }; + @Test public void testAmbiguityResolutionInNestedClassMethodBody_485388() throws Exception { parseAndCheckBindings(); } @@ -10319,6 +10784,7 @@ public void testAmbiguityResolutionInNestedClassMethodBody_485388() throws Excep // // template