Fix conformance test failures for Google.Protobuf
This commit is contained in:
parent
3cae867740
commit
e2e70a8a42
@ -1,33 +1,2 @@
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.UnpackedOutput.ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.BOOL[4].ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataScalarBinary.BOOL[6].ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.PackedOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.UnpackedOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.DefaultOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.PackedOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.UnpackedOutput.ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BOOL[4].ProtobufOutput
|
||||
Recommended.Proto3.ProtobufInput.ValidDataScalarBinary.BOOL[6].ProtobufOutput
|
||||
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput
|
||||
Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput
|
||||
Required.Proto2.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput
|
||||
Required.Proto2.ProtobufInput.ValidDataScalar.BOOL[4].ProtobufOutput
|
||||
Required.Proto2.ProtobufInput.ValidDataScalar.BOOL[6].ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.BOOL.JsonOutput
|
||||
Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.BOOL.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.UnpackedInput.ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[4].JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[4].ProtobufOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[6].JsonOutput
|
||||
Required.Proto3.ProtobufInput.ValidDataScalar.BOOL[6].ProtobufOutput
|
||||
Recommended.Proto2.ProtobufInput.ValidDataRepeated.BOOL.PackedInput.DefaultOutput.ProtobufOutput
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.JsonOutput
|
||||
Recommended.Proto3.JsonInput.BytesFieldBase64Url.ProtobufOutput
|
||||
|
@ -577,7 +577,32 @@ namespace Google.Protobuf
|
||||
/// </summary>
|
||||
public bool ReadBool()
|
||||
{
|
||||
return ReadRawVarint32() != 0;
|
||||
int result = 0; // can't do AND on bytes, it gets implicitly upcasted to int
|
||||
byte index = 0;
|
||||
if (bufferPos < bufferSize) // check if we have at least one byte for the most likely case of a one byte 1 or 0
|
||||
{
|
||||
result = buffer[bufferPos++];
|
||||
if (result < 128)
|
||||
{
|
||||
return result != 0;
|
||||
}
|
||||
result &= 0x7f;
|
||||
index++;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
byte b = ReadRawByte();
|
||||
result |= b & 0x7F; // OR all bytes together since we don't care about the actual value, just whether is more than zero
|
||||
if (b < 0x80)
|
||||
{
|
||||
return result != 0;
|
||||
}
|
||||
index++;
|
||||
}
|
||||
while (index < 10);
|
||||
|
||||
throw InvalidProtocolBufferException.MalformedVarint();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user