use of com.google.protobuf.Descriptors.FieldDescriptor in project core-java by SpineEventEngine.
the class FieldShould method pass_the_null_tolerance_check.
@Test
public void pass_the_null_tolerance_check() {
final FieldDescriptor defaultFieldDescriptor = StringValue.getDefaultInstance().getDescriptorForType().getFields().get(0);
new NullPointerTester().setDefault(TypeUrl.class, TypeUrl.of(StringValue.class)).setDefault(FieldDescriptor.class, defaultFieldDescriptor).testAllPublicStaticMethods(Messages.class);
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class PerformanceBenchmarks method testGetRepeatedFieldsWithDescriptors.
private static void testGetRepeatedFieldsWithDescriptors() {
TypicalData.Builder builder = TypicalData.newBuilder();
setAllRepeatedFields(builder, 25);
TypicalData data = builder.build();
List<FieldDescriptor> fields = getRepeatedFieldDescriptors();
for (int i = 0; i < 50; i++) {
for (int j = 0; j < 25; j++) {
for (FieldDescriptor field : fields) {
data.getRepeatedField(field, j);
}
}
}
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class CompatibilityTest method testEnumDescriptor.
public void testEnumDescriptor() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor fieldDescriptor = descriptor.findFieldByNumber(3);
assertEquals(Type.ENUM, fieldDescriptor.getType());
EnumDescriptor enumDescriptor = fieldDescriptor.getEnumType();
assertNotNull(enumDescriptor);
EnumValueDescriptor enumValueDescriptor = enumDescriptor.findValueByNumber(1);
assertEquals(1, enumValueDescriptor.getNumber());
assertEquals("VALUE1", enumValueDescriptor.getName());
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class CompatibilityTest method testClearFieldWithDescriptor.
public void testClearFieldWithDescriptor() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor intField = descriptor.findFieldByNumber(1);
FieldDescriptor repeatedIntField = descriptor.findFieldByNumber(4);
TypicalData.Builder dataBuilder = TypicalData.newBuilder().setMyInt(42).addRepeatedInt32(43).addRepeatedInt32(44);
assertEquals(42, dataBuilder.getMyInt());
dataBuilder.clearField(intField);
assertFalse(dataBuilder.hasMyInt());
assertEquals(2, dataBuilder.getRepeatedInt32Count());
dataBuilder.clearField(repeatedIntField);
assertEquals(0, dataBuilder.getRepeatedInt32Count());
}
use of com.google.protobuf.Descriptors.FieldDescriptor in project j2objc by google.
the class CompatibilityTest method testGetMessageType.
public void testGetMessageType() throws Exception {
Descriptor descriptor = TypicalData.Builder.getDescriptor();
FieldDescriptor fieldDescriptor = descriptor.findFieldByNumber(11);
Descriptor messageDescriptor = fieldDescriptor.getMessageType();
assertNotNull(messageDescriptor);
FieldDescriptor messageFieldDescriptor = messageDescriptor.findFieldByNumber(1);
assertEquals(1, messageFieldDescriptor.getNumber());
}
Aggregations