diff options
Diffstat (limited to 'chromium/components/safe_browsing_db/testing_util.h')
-rw-r--r-- | chromium/components/safe_browsing_db/testing_util.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/chromium/components/safe_browsing_db/testing_util.h b/chromium/components/safe_browsing_db/testing_util.h new file mode 100644 index 00000000000..76b319464c4 --- /dev/null +++ b/chromium/components/safe_browsing_db/testing_util.h @@ -0,0 +1,36 @@ +// Copyright (c) 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +// +// Utilities to be used in tests of safe_browsing_db/ component. + +#ifndef COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_ +#define COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_ + +#include "components/safe_browsing_db/util.h" + +#include <ostream> + +namespace safe_browsing { + +inline bool operator==(const ThreatMetadata& lhs, const ThreatMetadata& rhs) { + return lhs.threat_pattern_type == rhs.threat_pattern_type && + lhs.api_permissions == rhs.api_permissions && + lhs.population_id == rhs.population_id; +} + +inline bool operator!=(const ThreatMetadata& lhs, const ThreatMetadata& rhs) { + return !(lhs == rhs); +} + +inline std::ostream& operator<<(std::ostream& os, const ThreatMetadata& meta) { + os << "{threat_pattern_type=" << static_cast<int>(meta.threat_pattern_type) + << ", api_permissions=["; + for (auto p : meta.api_permissions) + os << p << ","; + return os << "], population_id=" << meta.population_id; +} + +} // namespace safe_browsing + +#endif // COMPONENTS_SAFE_BROWSING_DB_TESTING_UTIL_H_ |