diff --git a/app/test/processing/app/SerialTest.java b/app/test/processing/app/SerialTest.java index 63280811e..f63b8e994 100644 --- a/app/test/processing/app/SerialTest.java +++ b/app/test/processing/app/SerialTest.java @@ -29,6 +29,7 @@ package processing.app; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import org.junit.Test; @@ -47,6 +48,16 @@ public class SerialTest { String output = ""; } + @Test + public void testSerialUTF8DecoderWithInvalidChars() throws Exception { + NullSerial s = new NullSerial(); + byte[] testdata = new byte[] { '>', (byte) 0xC3, (byte) 0x28, '<' }; + byte[] expected = new byte[] { '>', (byte) 0xEF, (byte) 0xBF, (byte) 0xBD, (byte) 0x28, '<' }; + s.processSerialEvent(testdata); + byte[] res = s.output.getBytes("UTF-8"); + assertArrayEquals(expected, res); + } + @Test public void testSerialUTF8Decoder() throws Exception { NullSerial s = new NullSerial();