File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -190,6 +190,38 @@ public function test_normalize_answer_text_plain_unchanged() {
190190 );
191191 }
192192
193+ /**
194+ * A standalone literal carriage return (no following n) becomes one real newline.
195+ */
196+ public function test_normalize_answer_text_literal_lone_cr () {
197+ $ this ->assertSame (
198+ "line1 \nline2 " ,
199+ FaqSearchService::normalize_answer_text ( 'line1\rline2 ' )
200+ );
201+ }
202+
203+ /**
204+ * A real newline and a literal escape sequence in the same string both
205+ * end up as real newlines, with the pre-existing real newline untouched.
206+ */
207+ public function test_normalize_answer_text_mixed_real_and_literal_newline () {
208+ $ this ->assertSame (
209+ "line1 \nline2 \nline3 " ,
210+ FaqSearchService::normalize_answer_text ( "line1 \nline2 " . '\n ' . 'line3 ' )
211+ );
212+ }
213+
214+ /**
215+ * Normalization is idempotent: running it on already-normalized output
216+ * produces the same result as a single pass.
217+ */
218+ public function test_normalize_answer_text_idempotent () {
219+ $ input = 'a\r\nb\tc ' . "\n" . 'd ' ;
220+ $ once = FaqSearchService::normalize_answer_text ( $ input );
221+ $ twice = FaqSearchService::normalize_answer_text ( $ once );
222+ $ this ->assertSame ( $ once , $ twice );
223+ }
224+
193225 /**
194226 * The AI Overview mode defaults to conversation and honors option/filter.
195227 */
You can’t perform that action at this time.
0 commit comments