Add tests to cover handling negative varint.
The gtest will fail if the fix of b/77291057 isn't there. Should make this change in with the fix, but later than none. Bug: 77291057 Test: atest incidentd_test Change-Id: I48ece311f78ee18d97486839a3b8b434c9419cf3
This commit is contained in:
@@ -42,6 +42,7 @@ const std::string STRING_FIELD_2 = "\x12\vandroidwins";
|
||||
const std::string FIX64_FIELD_3 = "\x19\xff\xff\xff\xff\xff\xff\xff\xff"; // -1
|
||||
const std::string FIX32_FIELD_4 = "\x25\xff\xff\xff\xff"; // -1
|
||||
const std::string MESSAGE_FIELD_5 = "\x2a\x10" + VARINT_FIELD_1 + STRING_FIELD_2;
|
||||
const std::string NEGATIVE_VARINT_FIELD_6 = "\x30\xff\xff\xff\xff\xff\xff\xff\xff\xff\x01"; // -1
|
||||
|
||||
class PrivacyBufferTest : public Test {
|
||||
public:
|
||||
@@ -161,6 +162,11 @@ TEST_F(PrivacyBufferTest, StripLengthDelimitedField_Message) {
|
||||
assertStripByFields(DEST_EXPLICIT, "", 1, create_privacy(5, MESSAGE_TYPE, DEST_LOCAL));
|
||||
}
|
||||
|
||||
TEST_F(PrivacyBufferTest, StripNegativeVarint) {
|
||||
writeToFdBuffer(NEGATIVE_VARINT_FIELD_6);
|
||||
assertStripByFields(DEST_EXPLICIT, "", 1, create_privacy(6, OTHER_TYPE, DEST_LOCAL));
|
||||
}
|
||||
|
||||
TEST_F(PrivacyBufferTest, NoStripVarintField) {
|
||||
writeToFdBuffer(VARINT_FIELD_1);
|
||||
assertStripByFields(DEST_EXPLICIT, VARINT_FIELD_1, 1,
|
||||
@@ -191,6 +197,12 @@ TEST_F(PrivacyBufferTest, NoStripLengthDelimitedField_Message) {
|
||||
create_privacy(5, MESSAGE_TYPE, DEST_AUTOMATIC));
|
||||
}
|
||||
|
||||
TEST_F(PrivacyBufferTest, NoStripNegativeVarintField) {
|
||||
writeToFdBuffer(NEGATIVE_VARINT_FIELD_6);
|
||||
assertStripByFields(DEST_EXPLICIT, NEGATIVE_VARINT_FIELD_6, 1,
|
||||
create_privacy(6, OTHER_TYPE, DEST_AUTOMATIC));
|
||||
}
|
||||
|
||||
TEST_F(PrivacyBufferTest, StripVarintAndString) {
|
||||
writeToFdBuffer(STRING_FIELD_0 + VARINT_FIELD_1 + STRING_FIELD_2 + FIX64_FIELD_3 +
|
||||
FIX32_FIELD_4);
|
||||
|
||||
Reference in New Issue
Block a user