diff --git a/components/brave_ads/core/internal/serving/targeting/condition_matcher/condition_matcher_util_unittest.cc b/components/brave_ads/core/internal/serving/targeting/condition_matcher/condition_matcher_util_unittest.cc index 48669af20477..7e2b63790791 100644 --- a/components/brave_ads/core/internal/serving/targeting/condition_matcher/condition_matcher_util_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/condition_matcher/condition_matcher_util_unittest.cc @@ -46,7 +46,8 @@ TEST_F(BraveAdsConditionMatcherUtilTest, TEST_F(BraveAdsConditionMatcherUtilTest, MatchEqualOperatorCondition) { // Arrange - const ConditionMatcherMap condition_matchers = {{prefs::kServeAdAt, "[=]:7"}}; + const ConditionMatcherMap condition_matchers = { + {prefs::kServeAdAt, "[T=]:7"}}; AdvanceClockBy(base::Days(7)); @@ -56,7 +57,8 @@ TEST_F(BraveAdsConditionMatcherUtilTest, MatchEqualOperatorCondition) { TEST_F(BraveAdsConditionMatcherUtilTest, DoNotMatchEqualOperatorCondition) { // Arrange - const ConditionMatcherMap condition_matchers = {{prefs::kServeAdAt, "[=]:7"}}; + const ConditionMatcherMap condition_matchers = { + {prefs::kServeAdAt, "[T=]:7"}}; AdvanceClockBy(base::Days(7) - base::Milliseconds(1)); @@ -127,7 +129,7 @@ TEST_F(BraveAdsConditionMatcherUtilTest, // Arrange const ConditionMatcherMap condition_matchers = { {prefs::kOptedInToNotificationAds, "0"}, // Value is "1" in the pref. - {prefs::kServeAdAt, "[>]:7"}}; // 5 days ago in the pref. + {prefs::kServeAdAt, "[T>]:7"}}; // 5 days ago in the pref. AdvanceClockBy(base::Days(5)); 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 70182f66e87f..a2c00bb25a32 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 @@ -17,11 +17,11 @@ namespace brave_ads { namespace { -constexpr char kEqualOperatorConditionMatcherPrefix[] = "[=]:"; -constexpr char kGreaterThanOperatorConditionMatcherPrefix[] = "[>]:"; -constexpr char kGreaterThanOrEqualOperatorConditionMatcherPrefix[] = "[≥]:"; -constexpr char kLessThanOperatorConditionMatcherPrefix[] = "[<]:"; -constexpr char kLessThanOrEqualOperatorConditionMatcherPrefix[] = "[≤]:"; +constexpr char kEqualOperatorConditionMatcherPrefix[] = "[T=]:"; +constexpr char kGreaterThanOperatorConditionMatcherPrefix[] = "[T>]:"; +constexpr char kGreaterThanOrEqualOperatorConditionMatcherPrefix[] = "[T≥]:"; +constexpr char kLessThanOperatorConditionMatcherPrefix[] = "[T<]:"; +constexpr char kLessThanOrEqualOperatorConditionMatcherPrefix[] = "[T≤]:"; } // namespace 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 7016fb02d842..f786cc1afc76 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 @@ -24,7 +24,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, DoNotMatchMalformedOperator) { // Act & Assert EXPECT_FALSE(MatchEpochOperator( - "13372214400000000" /*1st October 2024 00:00:00 UTC*/, "[=]: 7 ")); + "13372214400000000" /*1st October 2024 00:00:00 UTC*/, "[T=]: 7 ")); } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchEqualOperator) { @@ -34,7 +34,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchEqualOperator) { // Act & Assert EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[=]:2")); // Event occurred 2 days ago. + "[T=]:2")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, DoNotMatchEqualOperator) { @@ -44,7 +44,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, DoNotMatchEqualOperator) { // Act & Assert EXPECT_FALSE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[=]:3")); // Event occurred 2 days ago. + "[T=]:3")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -55,7 +55,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[>]:1")); // Event occurred 2 days ago. + "[T>]:1")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -66,7 +66,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_FALSE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[>]:2")); // Event occurred 2 days ago. + "[T>]:2")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -77,10 +77,10 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≥]:1")); // Event occurred 2 days ago. + "[T≥]:1")); // Event occurred 2 days ago. EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≥]:2")); // Event occurred 2 days ago. + "[T≥]:2")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -91,7 +91,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_FALSE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≥]:3")); // Event occurred 2 days ago. + "[T≥]:3")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchLessThanOperator) { @@ -101,7 +101,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, MatchLessThanOperator) { // Act & Assert EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[<]:3")); // Event occurred 2 days ago. + "[T<]:3")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -112,7 +112,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_FALSE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[<]:2")); // Event occurred 2 days ago. + "[T<]:2")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -123,10 +123,10 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≤]:3")); // Event occurred 2 days ago. + "[T≤]:3")); // Event occurred 2 days ago. EXPECT_TRUE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≤]:2")); // Event occurred 2 days ago. + "[T≤]:2")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -137,7 +137,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_FALSE( MatchEpochOperator("13372214400000000" /*1st October 2024 00:00:00 UTC*/, - "[≤]:1")); // Event occurred 2 days ago. + "[T≤]:1")); // Event occurred 2 days ago. } TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, @@ -147,7 +147,7 @@ TEST_F(BraveAdsEpochOperatorConditionMatcherUtilTest, // Act & Assert EXPECT_FALSE(MatchEpochOperator( - "13372214400000000" /*1st October 2024 00:00:00 UTC*/, "[_]:2")); + "13372214400000000" /*1st October 2024 00:00:00 UTC*/, "[T_]:2")); } } // namespace brave_ads diff --git a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal.h b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal.h index 8128d00c2f44..e00ba69d37c0 100644 --- a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal.h +++ b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal.h @@ -16,7 +16,7 @@ class TimeDelta; namespace brave_ads { -inline constexpr char kEpochOperatorConditionMatcherPrefixPattern[] = "[?]:*"; +inline constexpr char kEpochOperatorConditionMatcherPrefixPattern[] = "[T?]:*"; // Parses a number of days from a condition. std::optional ParseDays(std::string_view condition); diff --git a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal_unittest.cc b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal_unittest.cc index b2bf6d04b2cc..02ddb946ef81 100644 --- a/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal_unittest.cc +++ b/components/brave_ads/core/internal/serving/targeting/condition_matcher/matchers/internal/epoch_operator_condition_matcher_util_internal_unittest.cc @@ -18,35 +18,35 @@ class BraveAdsOperatorConditionMatcherUtilInternalTest : public test::TestBase { TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, DoNotParseNegativeDays) { // Act & Assert - EXPECT_FALSE(ParseDays("[=]:-1")); + EXPECT_FALSE(ParseDays("[T=]:-1")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, ParseDayZero) { // Act & Assert - EXPECT_EQ(0, ParseDays("[=]:0")); + EXPECT_EQ(0, ParseDays("[T=]:0")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, ParseDays) { // Act & Assert - EXPECT_EQ(7, ParseDays("[=]:7")); + EXPECT_EQ(7, ParseDays("[T=]:7")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, DoNotParseNonIntegerDays) { // Act & Assert - EXPECT_FALSE(ParseDays("[=]:1.5")); + EXPECT_FALSE(ParseDays("[T=]:1.5")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, DoNotParseMalformedDays) { // Act & Assert - EXPECT_FALSE(ParseDays("[=]: 7 ")); + EXPECT_FALSE(ParseDays("[T=]: 7 ")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, DoNotParseInvalidDays) { // Act & Assert - EXPECT_FALSE(ParseDays("[=]:seven")); + EXPECT_FALSE(ParseDays("[T=]:seven")); } TEST_F(BraveAdsOperatorConditionMatcherUtilInternalTest, IsUnixEpochTimestamp) {