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:
parent
618eef0e0d
commit
782a35bf9e
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
package processing.app;
|
package processing.app;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -47,6 +48,16 @@ public class SerialTest {
|
|||||||
String output = "";
|
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
|
@Test
|
||||||
public void testSerialUTF8Decoder() throws Exception {
|
public void testSerialUTF8Decoder() throws Exception {
|
||||||
NullSerial s = new NullSerial();
|
NullSerial s = new NullSerial();
|
||||||
|
Loading…
Reference in New Issue
Block a user