diff --git a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util.cc b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util.cc index a2c00bb25a32..c021283e94b9 100644 --- a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util.cc +++ b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util.cc @@ -18,6 +18,7 @@ namespace brave_ads { namespace { constexpr char kEqualOperatorConditionMatcherPrefix[] = "[T=]:"; +constexpr char kNotEqualOperatorConditionMatcherPrefix[] = "[T≠]:"; constexpr char kGreaterThanOperatorConditionMatcherPrefix[] = "[T>]:"; constexpr char kGreaterThanOrEqualOperatorConditionMatcherPrefix[] = "[T≥]:"; constexpr char kLessThanOperatorConditionMatcherPrefix[] = "[T<]:"; @@ -50,6 +51,10 @@ bool MatchEpochOperator(const std::string_view value, return time_delta->InDays() == days; } + if (condition.starts_with(kNotEqualOperatorConditionMatcherPrefix)) { + return time_delta->InDays() != days; + } + if (condition.starts_with(kGreaterThanOperatorConditionMatcherPrefix)) { return time_delta->InDays() > days; } diff --git a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util_unittest.cc b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util_unittest.cc index f786cc1afc76..78a8ffbf177b 100644 --- a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/epoch_operator_condition_matcher_util_unittest.cc @@ -47,6 +47,27 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, DoNotMatchEqualOperator) { "[T=]:3")); // Event occurred 2 days ago. } +TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchNotEqualOperator) { + // Arrange + AdvanceClockTo(test::TimeFromUTCString("3 October 2024")); + + // Act & Assert + EXPECT_TRUE( + MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, + "[T≠]:3")); // Event occurred 2 days ago. +} + +TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, + DoNotMatchNotEqualOperator) { + // Arrange + AdvanceClockTo(test::TimeFromUTCString("3 October 2024")); + + // Act & Assert + EXPECT_FALSE( + MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, + "[T≠]:2")); // Event occurred 2 days ago. +} + TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchGreaterThanOperator) { // Arrange