use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testIOExceptionFromOutputStream.
public void testIOExceptionFromOutputStream() throws Exception {
// The issue being tested requires a proto that is larger than the CodedOutputStream buffer
// size.
TypicalData data;
try (InputStream in = getTestData("largeproto")) {
data = TypicalData.parseDelimitedFrom(in);
}
OutputStream out = new OutputStream() {
@Override
public void write(int b) throws IOException {
throw new IOException("test exception");
}
};
try {
data.writeTo(out);
fail("Expected IOException to be thrown.");
} catch (IOException e) {
// Expected
}
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testMutatingBuilderDoesntMutateMessage.
public void testMutatingBuilderDoesntMutateMessage() throws Exception {
TypicalData.Builder builder = TypicalData.newBuilder();
TypicalData data = builder.build();
builder.setMyInt(23);
assertEquals(0, data.getMyInt());
builder = data.toBuilder();
builder.setMyInt(45);
assertEquals(0, data.getMyInt());
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testWriteToOutputStream.
public void testWriteToOutputStream() throws Exception {
TypicalData data = TypicalData.newBuilder().setMyInt(7).setMyBool(true).setMyString("foo").setExtension(Typical.myPrimitiveExtension, 45).build();
ByteArrayOutputStream out = new ByteArrayOutputStream();
data.writeTo(out);
byte[] bytes = out.toByteArray();
byte[] expected = new byte[] { 0x08, 0x07, 0x60, 0x01, 0x7A, 0x03, 0x66, 0x6F, 0x6F, (byte) 0xC8, 0x3E, 0x2D };
checkBytes(expected, bytes);
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testNewBuilderWithPrototype.
public void testNewBuilderWithPrototype() throws Exception {
TypicalData data = TypicalData.newBuilder().setMyInt(123).build();
TypicalData.Builder builder = TypicalData.newBuilder(data);
assertEquals(123, builder.getMyInt());
}
use of protos.TypicalData in project j2objc by google.
the class CompatibilityTest method testSetAndGetRepeatedInt64.
public void testSetAndGetRepeatedInt64() throws Exception {
TypicalData data = TypicalData.newBuilder().addRepeatedInt64(123).build();
assertEquals(1, data.getRepeatedInt64Count());
assertEquals(123, data.getRepeatedInt64(0));
}
Aggregations