Function MUST write to out parameter on success, it was missing for last return true.
On the other hand we must never reach this line on a valid data.
In can happens only when decoding empty string.
Suggested test:
TEST(decode_unsigned_varint, empty_string){
uint32_t index = 0;
int64_t result = 123456789; // initialized with random data
EXPECT_FALSE(decode_unsigned_varint("", index, 0, result);
EXPECT_EQ(index, 0);
EXPECT_EQ(result, 123456789); // no writes to result on failure
}
Function MUST write to out parameter on success, it was missing for last return true. On the other hand we must never reach this line on a valid data. In can happens only when decoding empty string.
Suggested test:
TEST(decode_unsigned_varint, empty_string){ uint32_t index = 0; int64_t result = 123456789; // initialized with random data EXPECT_FALSE(decode_unsigned_varint("", index, 0, result); EXPECT_EQ(index, 0); EXPECT_EQ(result, 123456789); // no writes to result on failure }