MCPcopy Create free account
hub / github.com/bytedance/bolt / assertState

Function assertState

bolt/vector/tests/SelectivityVectorTest.cpp:39–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37namespace {
38
39void assertState(
40 const std::vector<bool>& expected,
41 const SelectivityVector& selectivityVector,
42 bool testProperties = true) {
43 ASSERT_EQ(expected.size(), selectivityVector.size());
44
45 size_t startIndexIncl = 0;
46 size_t endIndexExcl = 0;
47
48 size_t count = 0;
49
50 for (size_t i = 0; i < expected.size(); ++i) {
51 ASSERT_EQ(expected.at(i), selectivityVector.isValid(i))
52 << "Mismatch at index " << i
53 << ", selectivityVector: " << selectivityVector
54 << ", expected: " << ::testing::PrintToString(expected);
55 if (expected.at(i)) {
56 endIndexExcl = i + 1;
57 if (count == 0) {
58 startIndexIncl = i;
59 }
60
61 ++count;
62 }
63 }
64
65 if (testProperties) {
66 ASSERT_EQ(startIndexIncl, selectivityVector.begin()) << selectivityVector;
67 ASSERT_EQ(endIndexExcl, selectivityVector.end()) << selectivityVector;
68 ASSERT_EQ(startIndexIncl < endIndexExcl, selectivityVector.hasSelections())
69 << selectivityVector;
70 // countSelected relies on startIndexIncl and endIndexExcl being correct
71 // hence why it's inside this if block.
72 ASSERT_EQ(count, selectivityVector.countSelected());
73 }
74}
75
76void assertIsValid(
77 int from,

Callers 2

setValid_normalFunction · 0.85
TESTFunction · 0.85

Calls 7

isValidMethod · 0.80
hasSelectionsMethod · 0.80
countSelectedMethod · 0.80
sizeMethod · 0.45
atMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected