summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/safe_browsing/features_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/renderer/safe_browsing/features_unittest.cc')
-rw-r--r--chrome/renderer/safe_browsing/features_unittest.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/chrome/renderer/safe_browsing/features_unittest.cc b/chrome/renderer/safe_browsing/features_unittest.cc
index ad07ba2..ac5cb55 100644
--- a/chrome/renderer/safe_browsing/features_unittest.cc
+++ b/chrome/renderer/safe_browsing/features_unittest.cc
@@ -6,6 +6,7 @@
#include "base/format_macros.h"
#include "base/string_util.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
@@ -24,4 +25,20 @@ TEST(PhishingFeaturesTest, TooManyFeatures) {
EXPECT_EQ(FeatureMap::kMaxFeatureMapSize, features.features().size());
}
+TEST(PhishingFeaturesTest, IllegalFeatureValue) {
+ FeatureMap features;
+ EXPECT_FALSE(features.AddRealFeature("toosmall", -0.1));
+ EXPECT_TRUE(features.AddRealFeature("zero", 0.0));
+ EXPECT_TRUE(features.AddRealFeature("pointfive", 0.5));
+ EXPECT_TRUE(features.AddRealFeature("one", 1.0));
+ EXPECT_FALSE(features.AddRealFeature("toolarge", 1.1));
+
+ FeatureMap expected_features;
+ expected_features.AddRealFeature("zero", 0.0);
+ expected_features.AddRealFeature("pointfive", 0.5);
+ expected_features.AddRealFeature("one", 1.0);
+ EXPECT_THAT(features.features(),
+ ::testing::ContainerEq(expected_features.features()));
+}
+
} // namespace safe_browsing