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 testRawLittleEndian64Bytes() throws Exception { String n1 = "double1", n2 = "double2"; for (int i = 0; i < doubleValues.length; ) { double[] inner = doubleValues[i++]; int num = i; for (int j = 0; j < inner.length; j++) { long value = Double.doubleToRawLongBits(inner[j]); int tag = WireFormat.makeTag(num, FieldType.DOUBLE.wireType); int tagSize = CodedOutput.computeRawVarint32Size(tag); int expect = tagSize + CodedOutput.LITTLE_ENDIAN_64_SIZE; assertSize(n1, CodedOutput.computeDoubleSize(num, inner[j]), expect); assertSize(n2, CodedOutput.getTagAndRawLittleEndian64Bytes(tag, value).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); } } }
public void testRawLittleEndian32Bytes() throws Exception { String n1 = "float1", n2 = "float2"; for (int i = 0; i < floatValues.length; ) { float[] inner = floatValues[i++]; int num = i; for (int j = 0; j < inner.length; j++) { int value = Float.floatToRawIntBits(inner[j]); int valueSize = CodedOutput.LITTLE_ENDIAN_32_SIZE; int tag = WireFormat.makeTag(num, FieldType.FLOAT.wireType); int tagSize = CodedOutput.computeRawVarint32Size(tag); int expect = tagSize + valueSize; assertSize(n1, CodedOutput.computeFloatSize(num, inner[j]), expect); assertSize(n2, CodedOutput.getTagAndRawLittleEndian32Bytes(tag, value).length, expect); } } }