Add unit test to readU16

This commit is contained in:
Ehren Kret
2021-05-18 10:25:44 -05:00
parent f76e6705c0
commit 1a604d8c79
2 changed files with 47 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
package org.whispersystems.textsecuregcm.providers;
import com.google.common.annotations.VisibleForTesting;
import io.dropwizard.util.DataSizeUnit;
import java.io.IOException;
import java.io.InputStream;
@@ -132,7 +133,8 @@ public class MultiRecipientMessageProvider implements MessageBodyReader<MultiRec
* Reads two bytes with most significant byte first. Treats the value as unsigned so the range returned is
* {@code [0, 65535]}.
*/
private int readU16(InputStream stream) throws IOException {
@VisibleForTesting
static int readU16(InputStream stream) throws IOException {
int b1 = stream.read();
if (b1 == -1) {
throw new IOException("Missing byte 1 of U16");