Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b15d1e36 authored by Yi Jin's avatar Yi Jin Committed by android-build-merger
Browse files

Merge "Add tests to cover handling negative varint." into pi-dev

am: 9a58caaa

Change-Id: I0d7ee09e8d0243fa5dd82114431e8ca0135ed49a
parents 58bcc11e 9a58caaa
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -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);