Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: components/rappor/bloom_filter_unittest.cc

Issue 49753002: RAPPOR implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698