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]); | |
Ilya Sherman
2014/01/10 11:00:32
Why is line 15 unsigned and line 16 signed?
Steven Holte
2014/01/14 00:47:54
Done.
| |
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]); | |
Ilya Sherman
2014/01/10 11:00:32
nit: Please use EXPECT_EQ rather than ASSERT_EQ, t
Steven Holte
2014/01/14 00:47:54
Done.
| |
37 } | |
Ilya Sherman
2014/01/10 11:00:32
Please add some more testing of potential edge-cas
Steven Holte
2014/01/15 04:53:44
Done.
| |
38 | |
39 } // namespace rappor | |
OLD | NEW |