zoltanmeze commented on code in PR #518:
URL: https://github.com/apache/maven-surefire/pull/518#discussion_r847728655


##########
surefire-api/src/test/java/org/apache/maven/surefire/api/stream/AbstractStreamDecoderTest.java:
##########
@@ -258,6 +258,56 @@ public void shouldReadString() throws Exception
             .isEqualTo( "0123456789" );
     }
 
+    @Test
+    public void shouldReadStringOverflowOnNewLine() throws Exception
+    {
+        StringBuilder s = new StringBuilder( 1025 );
+        for ( int i = 0; i < 10; i++ )
+        {
+            s.append( PATTERN1 );
+        }
+        s.append( PATTERN1, 0, 23 );
+        s.append( "\u00FA\n" ); // 2-bytes encoded character + LF
+
+        Channel channel = new Channel( s.toString().getBytes( UTF_8 ), 
s.length() );
+
+        Mock thread = new Mock( channel, new MockForkNodeArguments(),
+            Collections.<Segment, ForkedProcessEventType>emptyMap() );
+
+        Memento memento = thread.new Memento();
+
+        assertThat( (String) invokeMethod( thread, "readString", memento, 1026 
) )
+            .isEqualTo( s.toString() );
+
+        assertThat ( memento.getByteBuffer().remaining() )
+            .isEqualTo( 0 );
+    }
+
+    @Test
+    public void shouldReadStringOverflowOn4BytesEncodedSymbol() throws 
Exception
+    {
+        StringBuilder s = new StringBuilder( 1024 );

Review Comment:
   Just realized this should be 1025 here, 😵 (`"\uD83D\uDE35"`) is actually 
counted as 2 characters.
   
   Do you want me to change this or just leave StringBuilder to increase the 
capacity on it's own?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to