Flutter Engine
The Flutter Engine
third_party
skia
tests
BitSetTest.cpp
Go to the documentation of this file.
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 "
src/utils/SkBitSet.h
"
9
#include "
tests/Test.h
"
10
11
#include <vector>
12
13
DEF_TEST
(BitSet,
reporter
) {
14
SkBitSet
set0(65536);
15
REPORTER_ASSERT
(
reporter
, set0.
size
() == 65536);
16
REPORTER_ASSERT
(
reporter
, set0.
test
(0) ==
false
);
17
REPORTER_ASSERT
(
reporter
, set0.
test
(32767) ==
false
);
18
REPORTER_ASSERT
(
reporter
, set0.
test
(65535) ==
false
);
19
REPORTER_ASSERT
(
reporter
, !set0.
findFirst
());
20
21
set0.
set
(22);
22
REPORTER_ASSERT
(
reporter
, set0.
test
(22) ==
true
);
23
REPORTER_ASSERT
(
reporter
, set0.
findFirst
());
24
REPORTER_ASSERT
(
reporter
, *set0.
findFirst
() == 22);
25
set0.
set
(24);
26
REPORTER_ASSERT
(
reporter
, set0.
test
(24) ==
true
);
27
REPORTER_ASSERT
(
reporter
, *set0.
findFirst
() == 22);
28
set0.
set
(35);
// on a different DWORD
29
REPORTER_ASSERT
(
reporter
, set0.
test
(35) ==
true
);
30
REPORTER_ASSERT
(
reporter
, *set0.
findFirst
() == 22);
31
REPORTER_ASSERT
(
reporter
, set0.
test
(24) ==
true
);
32
REPORTER_ASSERT
(
reporter
, set0.
test
(35) ==
true
);
33
set0.
set
(21);
34
REPORTER_ASSERT
(
reporter
, set0.
test
(21) ==
true
);
35
REPORTER_ASSERT
(
reporter
, *set0.
findFirst
() == 21);
36
set0.
reset
(21);
37
REPORTER_ASSERT
(
reporter
, set0.
test
(21) ==
false
);
38
REPORTER_ASSERT
(
reporter
, *set0.
findFirst
() == 22);
39
40
std::vector<unsigned int>
data
;
41
set0.
forEachSetIndex
([&
data
](
unsigned
v) {
data
.push_back(v); });
42
43
REPORTER_ASSERT
(
reporter
,
data
.size() == 3);
44
REPORTER_ASSERT
(
reporter
,
data
[0] == 22);
45
REPORTER_ASSERT
(
reporter
,
data
[1] == 24);
46
REPORTER_ASSERT
(
reporter
,
data
[2] == 35);
47
48
SkBitSet
set1(65536);
49
set1.
set
(12345);
50
REPORTER_ASSERT
(
reporter
, set0.
test
(12345) ==
false
);
51
REPORTER_ASSERT
(
reporter
, set1.
test
(12345) ==
true
);
52
REPORTER_ASSERT
(
reporter
, set1.
test
(22) ==
false
);
53
REPORTER_ASSERT
(
reporter
, set0.
test
(35) ==
true
);
54
55
set0.
reset
();
56
REPORTER_ASSERT
(
reporter
, !set0.
findFirst
());
57
REPORTER_ASSERT
(
reporter
, set0.
test
(1234) ==
false
);
58
59
set0.
set
();
60
REPORTER_ASSERT
(
reporter
, !set0.
findFirstUnset
());
61
REPORTER_ASSERT
(
reporter
, set0.
test
(5678) ==
true
);
62
}
DEF_TEST
DEF_TEST(BitSet, reporter)
Definition:
BitSetTest.cpp:13
reporter
reporter
Definition:
FontMgrTest.cpp:39
SkBitSet.h
Test.h
REPORTER_ASSERT
#define REPORTER_ASSERT(r, cond,...)
Definition:
Test.h:286
SkBitSet
Definition:
SkBitSet.h:21
SkBitSet::findFirst
OptionalIndex findFirst()
Definition:
SkBitSet.h:95
SkBitSet::set
void set(size_t index)
Definition:
SkBitSet.h:41
SkBitSet::test
bool test(size_t index) const
Definition:
SkBitSet.h:66
SkBitSet::forEachSetIndex
void forEachSetIndex(FN f) const
Definition:
SkBitSet.h:77
SkBitSet::size
size_t size() const
Definition:
SkBitSet.h:71
SkBitSet::reset
void reset(size_t index)
Definition:
SkBitSet.h:54
SkBitSet::findFirstUnset
OptionalIndex findFirstUnset()
Definition:
SkBitSet.h:109
data
std::shared_ptr< const fml::Mapping > data
Definition:
texture_gles.cc:63
Generated on Sun Jun 23 2024 21:56:37 for Flutter Engine by
1.9.4