Skip to content

Commit

Permalink
Enhanced: given_when_then pattern naming and formatting problems are …
Browse files Browse the repository at this point in the history
…resolved
  • Loading branch information
mnafshin committed Oct 7, 2019
1 parent da1ac65 commit 78cb7a3
Showing 1 changed file with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,28 @@ public void givenCharacterCh_whenConvertedtoBinaryWithEncodingUTF32_thenProduceR
}

@Test
public void givenUTF8String_decodeByUS_ASCII_ReplaceMalformedInputSequence() throws IOException {
String input = "The façade pattern is a software design pattern.";
Assertions.assertEquals("The fa��ade pattern is a software design pattern.",
CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPLACE));
public void givenUTF8String_whenDecodeByUS_ASCII_thenIgnoreMalformedInputSequence() throws IOException {
Assertions.assertEquals("The faade pattern is a software design pattern.",
CharacterEncodingExamples.decodeText(
"The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.IGNORE));
}

@Test
public void givenUTF8String_decodeByUS_ASCII_IgnoreMalformedInputSequence() throws IOException {
String input = "The façade pattern is a software design pattern.";
Assertions.assertEquals(
"The faade pattern is a software design pattern.",
CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.IGNORE));
public void givenUTF8String_whenDecodeByUS_ASCII_thenReplaceMalformedInputSequence() throws IOException {
Assertions.assertEquals("The fa��ade pattern is a software design pattern.",
CharacterEncodingExamples.decodeText(
"The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.REPLACE));
}

@Test
public void givenUTF8String_decodeByUS_ASCII_ReportMalformedInputSequence() {
String input = "The façade pattern is a software design pattern.";
public void givenUTF8String_whenDecodeByUS_ASCII_thenReportMalformedInputSequence() {
Assertions.assertThrows(MalformedInputException.class,
() -> CharacterEncodingExamples.decodeText(input, StandardCharsets.US_ASCII, CodingErrorAction.REPORT));
() -> CharacterEncodingExamples.decodeText(
"The façade pattern is a software design pattern.", StandardCharsets.US_ASCII, CodingErrorAction.REPORT));
}

@Test
public void givenTextFile_FindSuitableCandidateEncodings() {
public void givenTextFile_whenFindSuitableCandidateEncodings_thenProduceSuitableCandidateEncodings() {
Path path = Paths.get("src/test/resources/encoding.txt");
List<Charset> allCandidateCharSets = Arrays.asList(
StandardCharsets.US_ASCII, StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1);
Expand All @@ -113,6 +112,7 @@ public void givenTextFile_FindSuitableCandidateEncodings() {
ex.printStackTrace();
}
});

Assertions.assertEquals(suitableCharsets, Arrays.asList(StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1));
}

Expand Down

0 comments on commit 78cb7a3

Please sign in to comment.