mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 00:45:28 +02:00
Bug 372009 - Wrong class name in NonVirtualDestructor warning
This commit is contained in:
parent
4af78ed0b2
commit
e912eb6f32
3 changed files with 27 additions and 5 deletions
|
@ -9,6 +9,7 @@
|
|||
* Alena Laskavaia - initial API and implementation
|
||||
* Patrick Hofer [bug 315528]
|
||||
* Sergey Prigogin (Google)
|
||||
* Marc-Andre Laperle
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.internal.checkers;
|
||||
|
||||
|
@ -117,7 +118,7 @@ public class NonVirtualDestructor extends AbstractIndexAstChecker {
|
|||
node = decls[0];
|
||||
}
|
||||
}
|
||||
reportProblem(PROBLEM_ID, node, className.getSimpleID().toString(),
|
||||
reportProblem(PROBLEM_ID, node, new String(className.getSimpleID()),
|
||||
virtualMethod.getName());
|
||||
return PROCESS_SKIP;
|
||||
}
|
||||
|
|
|
@ -195,4 +195,12 @@ public class NonVirtualDestructorCheckerTest extends CheckerTestCase {
|
|||
loadCodeAndRun(getAboveComment());
|
||||
checkNoErrors();
|
||||
}
|
||||
|
||||
// class Foo {
|
||||
// virtual void bar();
|
||||
// };
|
||||
public void testBug372009_wrongClassNameInMessage() throws Exception {
|
||||
loadCodeAndRun(getAboveComment());
|
||||
assertMessageContains("Foo", markers[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2009, 2011 Alena Laskavaia
|
||||
* Copyright (c) 2009, 2012 Alena Laskavaia
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Alena Laskavaia - initial API and implementation
|
||||
* Marc-Andre Laperle
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.codan.core.test;
|
||||
|
||||
|
@ -186,9 +187,21 @@ public class CheckerTestCase extends CodanTestCase {
|
|||
*/
|
||||
public void assertMessageMatch(String pattern, IMarker m) {
|
||||
try {
|
||||
String attribute = (String) m.getAttribute(IMarker.MESSAGE);
|
||||
if (attribute.matches(pattern)) {
|
||||
fail("Expected " + attribute + " to match with /" + pattern //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String message = (String) m.getAttribute(IMarker.MESSAGE);
|
||||
if (message.matches(pattern)) {
|
||||
fail("Expected " + message + " to match with /" + pattern //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "/"); //$NON-NLS-1$
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void assertMessageContains(CharSequence charSequence, IMarker m) {
|
||||
try {
|
||||
String message = (String) m.getAttribute(IMarker.MESSAGE);
|
||||
if (!message.contains(charSequence)) {
|
||||
fail("Expected " + message + " to contain /" + charSequence //$NON-NLS-1$ //$NON-NLS-2$
|
||||
+ "/"); //$NON-NLS-1$
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
|
|
Loading…
Add table
Reference in a new issue