| 37 | namespace { |
| 38 | |
| 39 | void 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 | |
| 76 | void assertIsValid( |
| 77 | int from, |
no test coverage detected