@@ -74,29 +74,28 @@ public void givenCharacterCh_whenConvertedtoBinaryWithEncodingUTF32_thenProduceR
74
74
}
75
75
76
76
@ 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 ));
81
81
}
82
82
83
83
@ 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 ));
89
88
}
90
89
91
90
@ 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 () {
94
92
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 ));
96
95
}
97
96
98
97
@ Test
99
- public void givenTextFile_FindSuitableCandidateEncodings () {
98
+ public void givenTextFile_whenFindSuitableCandidateEncodings_thenProduceSuitableCandidateEncodings () {
100
99
Path path = Paths .get ("src/test/resources/encoding.txt" );
101
100
List <Charset > allCandidateCharSets = Arrays .asList (
102
101
StandardCharsets .US_ASCII , StandardCharsets .UTF_8 , StandardCharsets .ISO_8859_1 );
@@ -113,6 +112,7 @@ public void givenTextFile_FindSuitableCandidateEncodings() {
113
112
ex .printStackTrace ();
114
113
}
115
114
});
115
+
116
116
Assertions .assertEquals (suitableCharsets , Arrays .asList (StandardCharsets .UTF_8 , StandardCharsets .ISO_8859_1 ));
117
117
}
118
118
0 commit comments