Commit 96815032 authored by Jisi Liu's avatar Jisi Liu

partial oneof tests.

parent 7b72a24a
......@@ -3639,6 +3639,44 @@ public class NanoTest extends TestCase {
assertEquals(6, map.size());
}
private void checkOneofCase(TestAllTypesNano nano, int field)
throws Exception {
assertEquals(field, nano.getOneofFieldCase());
assertEquals(
field == TestAllTypesNano.ONEOF_BYTES_FIELD_NUMBER,
nano.hasOneofBytes());
assertEquals(
field == TestAllTypesNano.ONEOF_ENUM_FIELD_NUMBER,
nano.hasOneofEnum());
assertEquals(
field == TestAllTypesNano.ONEOF_FIXED64_FIELD_NUMBER,
nano.hasOneofFixed64());
assertEquals(
field == TestAllTypesNano.ONEOF_NESTED_MESSAGE_FIELD_NUMBER,
nano.hasOneofNestedMessage());
assertEquals(
field == TestAllTypesNano.ONEOF_STRING_FIELD_NUMBER,
nano.hasOneofString());
assertEquals(
field == TestAllTypesNano.ONEOF_UINT32_FIELD_NUMBER,
nano.hasOneofUint32());
}
public void testOneofBasic() throws Exception {
TestAllTypesNano m1 = new TestAllTypesNano();
checkOneofCase(m1, 0);
m1.setOneofString("hello");
checkOneofCase(m1, TestAllTypesNano.ONEOF_STRING_FIELD_NUMBER);
TestAllTypesNano m2 = new TestAllTypesNano();
m2.setOneofEnum(TestAllTypesNano.BAZ);
assertTrue(m2.hasOneofEnum());
assertEquals(
TestAllTypesNano.ONEOF_ENUM_FIELD_NUMBER, m2.getOneofFieldCase());
}
public void testNullRepeatedFields() throws Exception {
// Check that serialization after explicitly setting a repeated field
// to null doesn't NPE.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment