Index: test/FilterEngineStubs.cpp |
=================================================================== |
--- a/test/FilterEngineStubs.cpp |
+++ b/test/FilterEngineStubs.cpp |
@@ -2,115 +2,116 @@ |
#include <gtest/gtest.h> |
TEST(FilterEngineStubsTest, FilterCreation) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::FilterPtr filter1 = filterEngine.GetFilter("foo"); |
- ASSERT_EQ(filter1->GetProperty("type", -1), AdblockPlus::Filter::TYPE_BLOCKING); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, filter1->GetProperty("type", (int64_t)-1)); |
AdblockPlus::FilterPtr filter2 = filterEngine.GetFilter("@@foo"); |
- ASSERT_EQ(filter2->GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, filter2->GetProperty("type", (int64_t)-1)); |
AdblockPlus::FilterPtr filter3 = filterEngine.GetFilter("example.com##foo"); |
- ASSERT_EQ(filter3->GetProperty("type", -1), AdblockPlus::Filter::TYPE_ELEMHIDE); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE, filter3->GetProperty("type", (int64_t)-1)); |
AdblockPlus::FilterPtr filter4 = filterEngine.GetFilter("example.com#@#foo"); |
- ASSERT_EQ(filter4->GetProperty("type", -1), AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_ELEMHIDE_EXCEPTION, filter4->GetProperty("type", (int64_t)-1)); |
AdblockPlus::FilterPtr filter5 = filterEngine.GetFilter(" foo "); |
- ASSERT_EQ(filter5, filter1); |
+ ASSERT_EQ(*filter1, *filter5); |
} |
TEST(FilterEngineStubsTest, FilterProperties) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::FilterPtr filter = filterEngine.GetFilter("foo"); |
- ASSERT_EQ(filter->GetProperty("stringFoo", "x"), "x"); |
- ASSERT_EQ(filter->GetProperty("intFoo", 42), 42); |
+ ASSERT_EQ("x", filter->GetProperty("stringFoo", "x")); |
+ ASSERT_EQ(42, filter->GetProperty("intFoo", (int64_t)42)); |
ASSERT_EQ(filter->GetProperty("boolFoo", false), false); |
filter->SetProperty("stringFoo", "y"); |
- filter->SetProperty("intFoo", 24); |
+ filter->SetProperty("intFoo", (int64_t)24); |
filter->SetProperty("boolFoo", true); |
- ASSERT_EQ(filter->GetProperty("stringFoo", "x"), "y"); |
- ASSERT_EQ(filter->GetProperty("intFoo", 42), 24); |
+ ASSERT_EQ("y", filter->GetProperty("stringFoo", "x")); |
+ ASSERT_EQ(24, filter->GetProperty("intFoo", (int64_t)42)); |
ASSERT_EQ(filter->GetProperty("boolFoo", false), true); |
} |
TEST(FilterEngineStubsTest, AddRemoveFilters) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
AdblockPlus::FilterPtr filter = filterEngine.GetFilter("foo"); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
filter->AddToList(); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 1u); |
- ASSERT_EQ(filterEngine.GetListedFilters()[0], filter); |
+ ASSERT_EQ(1u, filterEngine.GetListedFilters().size()); |
+ ASSERT_EQ(*filter, *filterEngine.GetListedFilters()[0]); |
filter->AddToList(); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 1u); |
- ASSERT_EQ(filterEngine.GetListedFilters()[0], filter); |
+ ASSERT_EQ(1u, filterEngine.GetListedFilters().size()); |
+ ASSERT_EQ(*filter, *filterEngine.GetListedFilters()[0]); |
filter->RemoveFromList(); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
filter->RemoveFromList(); |
- ASSERT_EQ(filterEngine.GetListedFilters().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedFilters().size()); |
} |
TEST(FilterEngineStubsTest, SubscriptionProperties) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
- ASSERT_EQ(subscription->GetProperty("stringFoo", "x"), "x"); |
- ASSERT_EQ(subscription->GetProperty("intFoo", 42), 42); |
+ ASSERT_EQ("x", subscription->GetProperty("stringFoo", "x")); |
+ ASSERT_EQ(42, subscription->GetProperty("intFoo", (int64_t)42)); |
ASSERT_EQ(subscription->GetProperty("boolFoo", false), false); |
subscription->SetProperty("stringFoo", "y"); |
- subscription->SetProperty("intFoo", 24); |
+ subscription->SetProperty("intFoo", (int64_t)24); |
subscription->SetProperty("boolFoo", true); |
- ASSERT_EQ(subscription->GetProperty("stringFoo", "x"), "y"); |
- ASSERT_EQ(subscription->GetProperty("intFoo", 42), 24); |
+ ASSERT_EQ("y", subscription->GetProperty("stringFoo", "x")); |
+ ASSERT_EQ(24, subscription->GetProperty("intFoo", (int64_t)42)); |
ASSERT_EQ(subscription->GetProperty("boolFoo", false), true); |
} |
TEST(FilterEngineStubsTest, AddRemoveSubscriptions) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
subscription->AddToList(); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions()[0], subscription); |
+ ASSERT_EQ(1u, filterEngine.GetListedSubscriptions().size()); |
+ ASSERT_EQ(*subscription, *filterEngine.GetListedSubscriptions()[0]); |
subscription->AddToList(); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 1u); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions()[0], subscription); |
+ ASSERT_EQ(1u, filterEngine.GetListedSubscriptions().size()); |
+ ASSERT_EQ(*subscription, *filterEngine.GetListedSubscriptions()[0]); |
subscription->RemoveFromList(); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
subscription->RemoveFromList(); |
- ASSERT_EQ(filterEngine.GetListedSubscriptions().size(), 0u); |
+ ASSERT_EQ(0u, filterEngine.GetListedSubscriptions().size()); |
} |
TEST(FilterEngineStubsTest, Matches) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
AdblockPlus::FilterEngine filterEngine(jsEngine); |
- AdblockPlus::SubscriptionPtr subscription = filterEngine.GetSubscription("foo"); |
- subscription->AddToList(); |
- AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org", "", ""); |
+ filterEngine.GetFilter("adbanner.gif")->AddToList(); |
+ filterEngine.GetFilter("@@notbanner.gif")->AddToList(); |
+ |
+ AdblockPlus::FilterPtr match1 = filterEngine.Matches("http://example.org/foobar.gif", "IMAGE", ""); |
ASSERT_FALSE(match1); |
- AdblockPlus::FilterPtr match2 = filterEngine.Matches("http://example.org/adbanner.gif", "", ""); |
+ AdblockPlus::FilterPtr match2 = filterEngine.Matches("http://example.org/adbanner.gif", "IMAGE", ""); |
ASSERT_TRUE(match2); |
- ASSERT_EQ(match2->GetProperty("type", -1), AdblockPlus::Filter::TYPE_BLOCKING); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_BLOCKING, match2->GetProperty("type", (int64_t)-1)); |
- AdblockPlus::FilterPtr match3 = filterEngine.Matches("http://example.org/notbanner.gif", "", ""); |
+ AdblockPlus::FilterPtr match3 = filterEngine.Matches("http://example.org/notbanner.gif", "IMAGE", ""); |
ASSERT_TRUE(match3); |
- ASSERT_EQ(match3->GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match3->GetProperty("type", (int64_t)-1)); |
- AdblockPlus::FilterPtr match4 = filterEngine.Matches("http://example.org/notbanner.gif", "", ""); |
+ AdblockPlus::FilterPtr match4 = filterEngine.Matches("http://example.org/notbanner.gif", "IMAGE", ""); |
ASSERT_TRUE(match4); |
- ASSERT_EQ(match4->GetProperty("type", -1), AdblockPlus::Filter::TYPE_EXCEPTION); |
+ ASSERT_EQ(AdblockPlus::Filter::TYPE_EXCEPTION, match4->GetProperty("type", (int64_t)-1)); |
} |