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

Commit 97ae0814 authored by tsaichristine's avatar tsaichristine Committed by Christine Tsai
Browse files

Fix log matching unit test bug

- Update matcher in TestUidFieldMatcher unit test to have correct atom
id
- Add atom id check in matchesSimple

Test: bit statsd_test:AtomMatcher.TestUidFieldMatcher
Bug: 141174720
Fix: 141174720
Change-Id: Icbfea7e33876dea36d68d3e3d064581c5a621a77
parent 7c4334d2
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -358,9 +358,10 @@ bool matchesSimple(const UidMap& uidMap, const FieldValueMatcher& matcher,

bool matchesSimple(const UidMap& uidMap, const SimpleAtomMatcher& simpleMatcher,
                   const LogEvent& event) {
    if (simpleMatcher.field_value_matcher_size() <= 0) {
        return event.GetTagId() == simpleMatcher.atom_id();
    if (event.GetTagId() != simpleMatcher.atom_id()) {
        return false;
    }

    for (const auto& matcher : simpleMatcher.field_value_matcher()) {
        if (!matchesSimple(uidMap, matcher, event.getValues(), 0, event.getValues().size(), 0)) {
            return false;
+1 −0
Original line number Diff line number Diff line
@@ -330,6 +330,7 @@ TEST(AtomMatcherTest, TestUidFieldMatcher) {
    EXPECT_FALSE(matchesSimple(uidMap, *simpleMatcher, event));

    // Tag found in kAtomsWithUidField and has matching uid
    simpleMatcher->set_atom_id(TAG_ID_2);
    EXPECT_TRUE(matchesSimple(uidMap, *simpleMatcher, event2));

    // Tag found in kAtomsWithUidField but has non-matching uid