| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
@pigelvy thanks for the PR, here's a first round of comments (nothing major).
Sorry, something went wrong.
| } | ||
|
|
||
| /** | ||
| * Synonyme of {@link #isNotEncodedIn(Charset, boolean)} with {@code lenient = false}. |
There was a problem hiding this comment.
typo: Synonym (no e)
Sorry, something went wrong.
| * | ||
| * @param charset the expected encoding of the actual file. | ||
| * @return {@code this} assertion object. | ||
| * @since 3.26.4 |
There was a problem hiding this comment.
will be 3.27.0 thanks !
Sorry, something went wrong.
| .hasMessageContaining("line4 is nok"); | ||
| } | ||
|
|
||
| private File writeToTempFile(String str, Charset charset) { |
There was a problem hiding this comment.
I think this can be replaced by TempFileUtil createTempFileWithContent(String content, Charset charset) method
Sorry, something went wrong.
| assertThat(file).isEncodedIn(UTF_8, true); | ||
|
|
||
| // Test strict validation does not accept the replacement char | ||
| assertThatCode(() -> assertThat(file).isEncodedIn(UTF_8, false)) |
There was a problem hiding this comment.
Use AssertionsUtil.expectAssertionError instead to split the WHEN and THEN part of the test
Sorry, something went wrong.
| } | ||
|
|
||
| @Test | ||
| void should_validate_lenient() { |
There was a problem hiding this comment.
uaw GIVEN WHEN THEN comment to identify better the test steps
Sorry, something went wrong.
| * | ||
| * @author Ludovic VIEGAS | ||
| */ | ||
| public class ShouldBeEncodedIn extends BasicErrorMessageFactory { |
There was a problem hiding this comment.
Add a unit tests for this class as in ShouldBeCloseTo_create_Test
Sorry, something went wrong.
| throw failures.failure(info, shouldHaveNoParent(actual)); | ||
| } | ||
|
|
||
| public void assertIsEncodedIn(WritableAssertionInfo info, File actual, Charset charset, boolean lenient) { |
There was a problem hiding this comment.
use AssertionInfo instead of WritableAssertionInfo as we are not changing it
Sorry, something went wrong.
| * @author Ludovic VIEGAS | ||
| */ | ||
| public class EncodingIssue { | ||
| private final long line; |
There was a problem hiding this comment.
rename to lineNumber
Sorry, something went wrong.
| */ | ||
| public class EncodingIssue { | ||
| private final long line; | ||
| private final String string; |
There was a problem hiding this comment.
rename to line
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This PR adds isEncodedIn(Charset), isEncodedIn(Charset, boolean), isNotEncodedIn(Charset), isNotEncodedIn(Charset, boolean).
Even though detecting encoding issues might not be 100% possible because some charsets can simply map some inputs to something else valide to them, there are some cases where having assertions can be handly such as:
The assertions I added, are based on internal testing functions that I use in various projects. I though it would be a good addition to AssertJ.
Check List: