Skip to content

Commit

Permalink
Fix failing case in Bug528706CompletionWithMultilineTagsTest
Browse files Browse the repository at this point in the history
Adjust it to the available/known architectures since the update in
eclipse-platform/eclipse.platform#1576

And simplify AbstractTargetEditorTest.
  • Loading branch information
HannesWell committed Oct 3, 2024
1 parent 151075f commit e4fee78
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.eclipse.core.filebuffers.FileBuffers;
Expand Down Expand Up @@ -52,12 +54,7 @@ public abstract class AbstractTargetEditorTest {
protected File tempFile;

protected void checkProposals(String[] expectedProposals, ICompletionProposal[] actualProposals, int offset) {
assertEquals("Proposal lengths are not equal at offset " + offset + ". Actual: "
+ proposalListToString(actualProposals), expectedProposals.length, actualProposals.length);
for (int i = 0; i < actualProposals.length; i++) {
assertEquals("Proposal at index " + i + " did not match expected at offset " + offset,
actualProposals[i].getDisplayString(), expectedProposals[i]);
}
assertEquals(Arrays.asList(expectedProposals), toProposalStrings(actualProposals));
}

@Before
Expand Down Expand Up @@ -102,18 +99,11 @@ protected String proposalListToString(ICompletionProposal[] proposals) {
if (proposals == null) {
return "null";
}
if (proposals.length == 0) {
return "[]";
}
StringBuilder builder = new StringBuilder();
builder.append('[');
for (ICompletionProposal proposal : proposals) {
builder.append(proposal.getDisplayString());
builder.append(", ");
}
builder.setLength(builder.length() - 2);
builder.append(']');
return builder.toString();
return "[" + String.join(",", toProposalStrings(proposals)) + "]";
}

private static List<String> toProposalStrings(ICompletionProposal[] proposals) {
return Arrays.stream(proposals).map(ICompletionProposal::getDisplayString).toList();
}

public static ITextFileBuffer getTextFileBufferFromFile(File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.pde.genericeditor.extension.tests;

import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.text.ITextViewer;
import org.junit.Before;
import org.junit.Test;
Expand Down Expand Up @@ -49,8 +50,7 @@ public void testTagValueCompletionAsAMultiline() {

@Test
public void testTagValueCompletionAfterAMultiline() {
checkProposals(new String[] { "x86", "x86_64" },
contentAssist.computeCompletionProposals(textViewer, 181 + 1), 181);
checkProposals(Platform.knownOSArchValues(), contentAssist.computeCompletionProposals(textViewer, 181), 181);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
linu

</os>
<arch>x</arch>
<arch></arch>
</environment>
</target>

0 comments on commit e4fee78

Please sign in to comment.