@@ -74,29 +74,28 @@ public void givenCharacterCh_whenConvertedtoBinaryWithEncodingUTF32_thenProduceR
7474 }
7575
7676 @ Test
77- public void givenUTF8String_decodeByUS_ASCII_ReplaceMalformedInputSequence () throws IOException {
78- String input = "The façade pattern is a software design pattern." ;
79- Assertions . assertEquals ( "The fa��ade pattern is a software design pattern." ,
80- CharacterEncodingExamples . decodeText ( input , StandardCharsets .US_ASCII , CodingErrorAction .REPLACE ));
77+ public void givenUTF8String_whenDecodeByUS_ASCII_thenIgnoreMalformedInputSequence () throws IOException {
78+ Assertions . assertEquals ( "The faade pattern is a software design pattern." ,
79+ CharacterEncodingExamples . decodeText (
80+ "The façade pattern is a software design pattern." , StandardCharsets .US_ASCII , CodingErrorAction .IGNORE ));
8181 }
8282
8383 @ Test
84- public void givenUTF8String_decodeByUS_ASCII_IgnoreMalformedInputSequence () throws IOException {
85- String input = "The façade pattern is a software design pattern." ;
86- Assertions .assertEquals (
87- "The faade pattern is a software design pattern." ,
88- CharacterEncodingExamples .decodeText (input , StandardCharsets .US_ASCII , CodingErrorAction .IGNORE ));
84+ public void givenUTF8String_whenDecodeByUS_ASCII_thenReplaceMalformedInputSequence () throws IOException {
85+ Assertions .assertEquals ("The fa��ade pattern is a software design pattern." ,
86+ CharacterEncodingExamples .decodeText (
87+ "The façade pattern is a software design pattern." , StandardCharsets .US_ASCII , CodingErrorAction .REPLACE ));
8988 }
9089
9190 @ Test
92- public void givenUTF8String_decodeByUS_ASCII_ReportMalformedInputSequence () {
93- String input = "The façade pattern is a software design pattern." ;
91+ public void givenUTF8String_whenDecodeByUS_ASCII_thenReportMalformedInputSequence () {
9492 Assertions .assertThrows (MalformedInputException .class ,
95- () -> CharacterEncodingExamples .decodeText (input , StandardCharsets .US_ASCII , CodingErrorAction .REPORT ));
93+ () -> CharacterEncodingExamples .decodeText (
94+ "The façade pattern is a software design pattern." , StandardCharsets .US_ASCII , CodingErrorAction .REPORT ));
9695 }
9796
9897 @ Test
99- public void givenTextFile_FindSuitableCandidateEncodings () {
98+ public void givenTextFile_whenFindSuitableCandidateEncodings_thenProduceSuitableCandidateEncodings () {
10099 Path path = Paths .get ("src/test/resources/encoding.txt" );
101100 List <Charset > allCandidateCharSets = Arrays .asList (
102101 StandardCharsets .US_ASCII , StandardCharsets .UTF_8 , StandardCharsets .ISO_8859_1 );
@@ -113,6 +112,7 @@ public void givenTextFile_FindSuitableCandidateEncodings() {
113112 ex .printStackTrace ();
114113 }
115114 });
115+
116116 Assertions .assertEquals (suitableCharsets , Arrays .asList (StandardCharsets .UTF_8 , StandardCharsets .ISO_8859_1 ));
117117 }
118118
0 commit comments