mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Removed the restriction that transport updates have to be written in
delimited form.
This commit is contained in:
@@ -4,6 +4,7 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -485,6 +486,31 @@ public class ReaderImplTest extends TestCase {
|
||||
assertEquals("bar", e.getValue().s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMaxLengthAppliesInsideMap() throws Exception {
|
||||
setContents("B" + "1" + "83666F6F" + "93010203");
|
||||
r.setMaxStringLength(3);
|
||||
r.setMaxBytesLength(3);
|
||||
Map<String, Bytes> m = r.readMap(String.class, Bytes.class);
|
||||
String key = "foo";
|
||||
Bytes value = new Bytes(new byte[] {1, 2, 3});
|
||||
assertEquals(Collections.singletonMap(key, value), m);
|
||||
// The max string length should be applied inside the map
|
||||
setContents("B" + "1" + "83666F6F" + "93010203");
|
||||
r.setMaxStringLength(2);
|
||||
try {
|
||||
r.readMap(String.class, Bytes.class);
|
||||
fail();
|
||||
} catch(FormatException expected) {}
|
||||
// The max bytes length should be applied inside the map
|
||||
setContents("B" + "1" + "83666F6F" + "93010203");
|
||||
r.setMaxBytesLength(2);
|
||||
try {
|
||||
r.readMap(String.class, Bytes.class);
|
||||
fail();
|
||||
} catch(FormatException expected) {}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReadEmptyInput() throws Exception {
|
||||
setContents("");
|
||||
|
||||
Reference in New Issue
Block a user