diff options
author | Sergey Prigogin | 2016-10-28 03:15:31 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2016-10-28 14:22:51 +0000 |
commit | 64bd99d429b2ad14d250c687a9ca238bd6412316 (patch) | |
tree | 038a958bc9120264030c9098d6fadbeb788553e7 /core/org.eclipse.cdt.core.tests/suite | |
parent | f8488ac157e6eb1a718c395976359a85fe6fb60c (diff) | |
download | org.eclipse.cdt-64bd99d429b2ad14d250c687a9ca238bd6412316.tar.gz org.eclipse.cdt-64bd99d429b2ad14d250c687a9ca238bd6412316.tar.xz org.eclipse.cdt-64bd99d429b2ad14d250c687a9ca238bd6412316.zip |
Improved diagnostic messages in tests.
Change-Id: I031061fa7ce8c7cf5af76f229ff9b93c411d1be3
Diffstat (limited to 'core/org.eclipse.cdt.core.tests/suite')
-rw-r--r-- | core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java index 385e81a5da3..3fe5a87c31b 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/BaseTestCase.java @@ -24,14 +24,8 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import junit.framework.AssertionFailedError; -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestFailure; -import junit.framework.TestResult; -import junit.framework.TestSuite; - import org.eclipse.cdt.core.CCorePlugin; +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; @@ -54,6 +48,13 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.jobs.Job; +import junit.framework.AssertionFailedError; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestFailure; +import junit.framework.TestResult; +import junit.framework.TestSuite; + public class BaseTestCase extends TestCase { private static final String DEFAULT_INDEXER_TIMEOUT_SEC = "10"; private static final String INDEXER_TIMEOUT_PROPERTY = "indexer.timeout"; @@ -368,4 +369,20 @@ public class BaseTestCase extends TestCase { protected static void assertVariableValue(IVariable var, long expectedValue) { assertValue(var.getInitialValue(), expectedValue); } + + protected static String formatForPrinting(IASTName name) { + String signature = name.getRawSignature(); + boolean saved = CPPASTNameBase.sAllowNameComputation; + CPPASTNameBase.sAllowNameComputation = true; + try { + String nameStr = name.toString(); + if (signature.replace(" ", "").equals(nameStr.replace(" ", ""))) + return signature; + return nameStr + " in " + signature; + } catch (Throwable e) { + return signature; + } finally { + CPPASTNameBase.sAllowNameComputation = saved; + } + } } |