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
DEF_TEST(BitSet,reporter)11 DEF_TEST(BitSet, reporter) {
12 SkBitSet set0(65536);
13 REPORTER_ASSERT(reporter, set0.has(0) == false);
14 REPORTER_ASSERT(reporter, set0.has(32767) == false);
15 REPORTER_ASSERT(reporter, set0.has(65535) == false);
16
17 set0.set(22);
18 REPORTER_ASSERT(reporter, set0.has(22) == true);
19 set0.set(24);
20 REPORTER_ASSERT(reporter, set0.has(24) == true);
21 set0.set(35); // on a different DWORD
22 REPORTER_ASSERT(reporter, set0.has(35) == true);
23 REPORTER_ASSERT(reporter, set0.has(24) == true);
24 REPORTER_ASSERT(reporter, set0.has(35) == true);
25
26 SkTDArray<unsigned int> data;
27 set0.exportTo(&data);
28 REPORTER_ASSERT(reporter, data.count() == 3);
29 REPORTER_ASSERT(reporter, data[0] == 22);
30 REPORTER_ASSERT(reporter, data[1] == 24);
31 REPORTER_ASSERT(reporter, data[2] == 35);
32
33 SkBitSet set1(65536);
34 set1.set(12345);
35 REPORTER_ASSERT(reporter, set0.has(12345) == false);
36 REPORTER_ASSERT(reporter, set1.has(12345) == true);
37 REPORTER_ASSERT(reporter, set1.has(22) == false);
38 REPORTER_ASSERT(reporter, set0.has(35) == true);
39 }
40