mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Avoid calling StringBuffer.append(CharSequence s) with a StringBuffer as argument, bug 220158.
This commit is contained in:
parent
eda39314e7
commit
5171001393
3 changed files with 48 additions and 2 deletions
|
@ -0,0 +1,41 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
||||||
|
* All rights reserved. This program and the accompanying materials
|
||||||
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
* which accompanies this distribution, and is available at
|
||||||
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
|
*
|
||||||
|
* Contributors:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
package org.eclipse.cdt.core.internal.tests;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
public class StringBuilderTest extends TestCase {
|
||||||
|
public static Test suite() {
|
||||||
|
return new TestSuite(StringBuilderTest.class, "StringBuilderTest");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSafe() {
|
||||||
|
StringBuilder b1= new StringBuilder();
|
||||||
|
StringBuilder b2= new StringBuilder();
|
||||||
|
b1.append("a");
|
||||||
|
b2.append("b");
|
||||||
|
CharSequence cs= b2;
|
||||||
|
b1.append(cs);
|
||||||
|
assertEquals("ab", b1.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testBug220158() {
|
||||||
|
StringBuilder b1= new StringBuilder();
|
||||||
|
StringBuilder b2= new StringBuilder();
|
||||||
|
b1.append("a");
|
||||||
|
b2.append("b");
|
||||||
|
b1.append(b2);
|
||||||
|
assertEquals("ab", b1.toString());
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -24,6 +24,7 @@ import junit.framework.TestSuite;
|
||||||
import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorTests;
|
import org.eclipse.cdt.core.cdescriptor.tests.CDescriptorTests;
|
||||||
import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTests;
|
import org.eclipse.cdt.core.internal.errorparsers.tests.ErrorParserTests;
|
||||||
import org.eclipse.cdt.core.internal.tests.PositionTrackerTests;
|
import org.eclipse.cdt.core.internal.tests.PositionTrackerTests;
|
||||||
|
import org.eclipse.cdt.core.internal.tests.StringBuilderTest;
|
||||||
import org.eclipse.cdt.core.language.AllLanguageTests;
|
import org.eclipse.cdt.core.language.AllLanguageTests;
|
||||||
import org.eclipse.cdt.core.model.tests.AllCoreTests;
|
import org.eclipse.cdt.core.model.tests.AllCoreTests;
|
||||||
import org.eclipse.cdt.core.model.tests.BinaryTests;
|
import org.eclipse.cdt.core.model.tests.BinaryTests;
|
||||||
|
@ -68,6 +69,7 @@ public class AutomatedIntegrationSuite extends TestSuite {
|
||||||
suite.addTest(ElementDeltaTests.suite());
|
suite.addTest(ElementDeltaTests.suite());
|
||||||
suite.addTest(WorkingCopyTests.suite());
|
suite.addTest(WorkingCopyTests.suite());
|
||||||
suite.addTest(PositionTrackerTests.suite());
|
suite.addTest(PositionTrackerTests.suite());
|
||||||
|
suite.addTest(StringBuilderTest.suite());
|
||||||
suite.addTest(AllLanguageTests.suite());
|
suite.addTest(AllLanguageTests.suite());
|
||||||
|
|
||||||
// Add in PDOM tests
|
// Add in PDOM tests
|
||||||
|
|
|
@ -124,7 +124,10 @@ public class MacroExpansionTracker {
|
||||||
StringBuilder after= new StringBuilder();
|
StringBuilder after= new StringBuilder();
|
||||||
toString(result, lexInput, before, replace, after);
|
toString(result, lexInput, before, replace, after);
|
||||||
int offset= before.length();
|
int offset= before.length();
|
||||||
before.append(replace).append(after);
|
// workaround bug 220158
|
||||||
|
final CharSequence csr= replace;
|
||||||
|
final CharSequence csa= after;
|
||||||
|
before.append(csr).append(csa);
|
||||||
before.append(lexInput, endOffset, lexInput.length-endOffset);
|
before.append(lexInput, endOffset, lexInput.length-endOffset);
|
||||||
fPreStep= before.toString();
|
fPreStep= before.toString();
|
||||||
fReplacement= new ReplaceEdit(offset, replace.length(), fReplacementText);
|
fReplacement= new ReplaceEdit(offset, replace.length(), fReplacementText);
|
||||||
|
|
Loading…
Add table
Reference in a new issue