• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2011 Google Inc.
3  *
4  * Use of this source code is governed by a BSD-style license that can be
5  * found in the LICENSE file.
6  */
7 
8 #include "SkBitSet.h"
9 #include "Test.h"
10 
11 #include <vector>
12 
DEF_TEST(BitSet,reporter)13 DEF_TEST(BitSet, reporter) {
14     SkBitSet set0(65536);
15     REPORTER_ASSERT(reporter, set0.has(0) == false);
16     REPORTER_ASSERT(reporter, set0.has(32767) == false);
17     REPORTER_ASSERT(reporter, set0.has(65535) == false);
18 
19     set0.set(22);
20     REPORTER_ASSERT(reporter, set0.has(22) == true);
21     set0.set(24);
22     REPORTER_ASSERT(reporter, set0.has(24) == true);
23     set0.set(35);  // on a different DWORD
24     REPORTER_ASSERT(reporter, set0.has(35) == true);
25     REPORTER_ASSERT(reporter, set0.has(24) == true);
26     REPORTER_ASSERT(reporter, set0.has(35) == true);
27 
28     std::vector<unsigned int> data;
29     set0.getSetValues([&data](unsigned v) { data.push_back(v); });
30 
31     REPORTER_ASSERT(reporter, data.size() == 3);
32     REPORTER_ASSERT(reporter, data[0] == 22);
33     REPORTER_ASSERT(reporter, data[1] == 24);
34     REPORTER_ASSERT(reporter, data[2] == 35);
35 
36     SkBitSet set1(65536);
37     set1.set(12345);
38     REPORTER_ASSERT(reporter, set0.has(12345) == false);
39     REPORTER_ASSERT(reporter, set1.has(12345) == true);
40     REPORTER_ASSERT(reporter, set1.has(22) == false);
41     REPORTER_ASSERT(reporter, set0.has(35) == true);
42 }
43