public void testBool() throws Exception { int num = 1; boolean value = true; int valueSize = 1; int tag = WireFormat.makeTag(num, FieldType.BOOL.wireType); int tagSize = CodedOutput.computeRawVarint32Size(tag); int expect = tagSize + valueSize; assertSize("boolean1", CodedOutput.computeBoolSize(num, value), expect); assertSize("boolean2", CodedOutput.getTagAndRawVarInt32Bytes(tag, 1).length, expect); }
public void testRawVarInt32Bytes() throws Exception { String n1 = "int1", n2 = "int2"; for (int i = 0; i < int32values.length; ) { int[] inner = int32values[i++]; int num = i; for (int j = 0; j < inner.length; j++) { int value = inner[j]; int valueSize = CodedOutput.computeRawVarint32Size(value); int tag = WireFormat.makeTag(num, FieldType.INT32.wireType); int tagSize = CodedOutput.computeRawVarint32Size(tag); int expect = tagSize + valueSize; assertSize(n1, CodedOutput.computeInt32Size(num, value), expect); assertSize(n2, CodedOutput.getTagAndRawVarInt32Bytes(tag, value).length, expect); } } }