OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/rappor/bloom_filter.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace rappor { |
| 10 |
| 11 TEST(BloomFilterTest, TestAddString) { |
| 12 BloomFilter filter(2, 2); |
| 13 |
| 14 ASSERT_EQ(2u, filter.bytes().size()); |
| 15 ASSERT_EQ(0u, filter.bytes()[0]); |
| 16 ASSERT_EQ(0, filter.bytes()[1]); |
| 17 |
| 18 filter.AddString("Foo"); |
| 19 ASSERT_EQ(2u, filter.bytes()[0]); |
| 20 ASSERT_EQ(8u, filter.bytes()[1]); |
| 21 |
| 22 filter.AddString("Bar"); |
| 23 ASSERT_EQ(3u, filter.bytes()[0]); |
| 24 ASSERT_EQ(9u, filter.bytes()[1]); |
| 25 } |
| 26 |
| 27 TEST(BloomFilterTest, TestAddStrings) { |
| 28 BloomFilter filter(2, 2); |
| 29 std::vector<std::string> strs; |
| 30 strs.push_back("Bar"); |
| 31 strs.push_back("Foo"); |
| 32 filter.AddStrings(strs); |
| 33 |
| 34 ASSERT_EQ(2u, filter.bytes().size()); |
| 35 ASSERT_EQ(3u, filter.bytes()[0]); |
| 36 ASSERT_EQ(9u, filter.bytes()[1]); |
| 37 } |
| 38 |
| 39 } // namespace rappor |
OLD | NEW |