1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-28 09:24:14 +01:00

Added test for invalid UTF-8 sequences

This commit is contained in:
Cristian Maglie 2020-06-19 16:06:18 +02:00
parent 618eef0e0d
commit 782a35bf9e

View File

@ -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();