Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests to use assertThat instead of assertEquals #1087

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

/**
Expand Down Expand Up @@ -94,10 +93,10 @@ void testIncludeAnalysisFromNumberedInclude() {

Include ia = Include.fromNumberedInclude(content, 2,
String.format("// _include::%d-%d:%s", expectedStartWithinBlock, expectedEndWithinBlock, expectedIncludeTarget));
assertEquals(expectedStartWithinBlock, ia.startWithinBlock(), "unexpected starting line number");
assertEquals(expectedEndWithinBlock, ia.endWithinBlock(), "unexpected ending line number");
assertEquals(includedContent, ia.body(), "unexpected body");
assertEquals(expectedIncludeTarget, ia.includeTarget(), "unexpected include target");
assertThat("unexpected starting line number", ia.startWithinBlock(), is(expectedStartWithinBlock));
assertThat("unexpected ending line number", ia.endWithinBlock(), is(expectedEndWithinBlock));
assertThat("unexpected body", ia.body(), is(includedContent));
assertThat("unexpected include target", ia.includeTarget(), is(expectedIncludeTarget));
}

@Test
Expand All @@ -124,11 +123,11 @@ void testIncludeAnalysisFromBracketedInclude() {
List<String> result = new ArrayList<>();
Include ia = Include.consumeBracketedInclude(content, lineNumber, result, result.size());

assertEquals(expectedStartWithinBlock, ia.startWithinBlock(), "unexpected start within block");
assertEquals(expectedEndWithinBlock, ia.endWithinBlock(), "unexpected end within block");
assertEquals(includedContent, ia.body(), "unexpected body");
assertEquals(expectedIncludeTarget, ia.includeTarget(), "unexpected include target");
assertEquals(expectedFinalLineAfterConsuming, lineNumber.get(), "unexpected final line number");
assertThat("unexpected start within block", ia.startWithinBlock(), is(expectedStartWithinBlock));
assertThat("unexpected end within block", ia.endWithinBlock(), is(expectedEndWithinBlock));
assertThat("unexpected body", ia.body(), is(includedContent));
assertThat("unexpected include target", ia.includeTarget(), is(expectedIncludeTarget));
assertThat("unexpected final line number", lineNumber.get(), is(expectedFinalLineAfterConsuming));
}

@Test
Expand Down Expand Up @@ -242,8 +241,8 @@ void testOverallConversion() throws DiffException {

List<String> numberedContent = IncludePreprocessor.convertBracketedToNumbered(content);

assertEquals(expectedNumberedContent, numberedContent, "overall resulting content did not match; " +
DiffUtils.diff(expectedNumberedContent, numberedContent));
assertThat("overall resulting content did not match; " +
DiffUtils.diff(expectedNumberedContent, numberedContent), numberedContent, is(expectedNumberedContent));
}

@Test
Expand All @@ -260,10 +259,11 @@ void testInitialProcessing() throws IOException, DiffException, URISyntaxExcepti
List<String> actualAfterInitialPreprocessingLines =
IncludePreprocessor.convertHybridToBracketed(originalLines);

assertEquals(expectedAfterInitialPreprocessingLines,
actualAfterInitialPreprocessingLines,
assertThat("overall resulting content did not match; " +
DiffUtils.diff(expectedAfterInitialPreprocessingLines,
actualAfterInitialPreprocessingLines).toString());
actualAfterInitialPreprocessingLines),
actualAfterInitialPreprocessingLines,
is(expectedAfterInitialPreprocessingLines));
}

private List<String> loadFromPath(Path path) throws URISyntaxException, IOException {
Expand Down Expand Up @@ -320,8 +320,7 @@ void testSourceBlockIncludeBracketing() throws DiffException {
Block sba = Block.consumeBlock(orig, lineNumber);

List<String> bracketed = sba.asBracketedBlock();
assertEquals(expectedBracketed, bracketed,
DiffUtils.diff(orig, bracketed).toString());
assertThat("overall resulting content did not match; " + DiffUtils.diff(orig, bracketed).toString(), bracketed, is(expectedBracketed));
}

private static List<String> asList(String text) {
Expand Down
Loading