epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | */ |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 7 | |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 8 | #include "SkBitSet.h" |
tfarina@chromium.org | 8f6884a | 2014-01-24 20:56:26 +0000 | [diff] [blame] | 9 | #include "Test.h" |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 10 | |
tfarina@chromium.org | e4fafb1 | 2013-12-12 21:11:12 +0000 | [diff] [blame] | 11 | DEF_TEST(BitSet, reporter) { |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 12 | SkBitSet set0(65536); |
halcanary | e2348cc | 2016-08-19 16:23:23 -0700 | [diff] [blame] | 13 | REPORTER_ASSERT(reporter, set0.has(0) == false); |
| 14 | REPORTER_ASSERT(reporter, set0.has(32767) == false); |
| 15 | REPORTER_ASSERT(reporter, set0.has(65535) == false); |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 16 | |
halcanary | e2348cc | 2016-08-19 16:23:23 -0700 | [diff] [blame] | 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); |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 25 | |
vandebo@chromium.org | 17e66e2 | 2011-07-27 20:59:55 +0000 | [diff] [blame] | 26 | SkTDArray<unsigned int> data; |
| 27 | set0.exportTo(&data); |
halcanary | e2348cc | 2016-08-19 16:23:23 -0700 | [diff] [blame] | 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); |
vandebo@chromium.org | 17e66e2 | 2011-07-27 20:59:55 +0000 | [diff] [blame] | 32 | |
halcanary | e2348cc | 2016-08-19 16:23:23 -0700 | [diff] [blame] | 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); |
vandebo@chromium.org | d3a8c94 | 2011-07-02 01:26:37 +0000 | [diff] [blame] | 39 | } |