MCPcopy Create free account
hub / github.com/ceph/ceph / validate_iterator

Method validate_iterator

src/test/ObjectMap/test_keyvaluedb_iterators.cc:93–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91 }
92
93 ::testing::AssertionResult validate_iterator(
94 KeyValueDB::WholeSpaceIterator it,
95 string expected_prefix,
96 const string &expected_key,
97 const string &expected_value) {
98 if (!it->valid()) {
99 return ::testing::AssertionFailure()
100 << __func__
101 << " iterator not valid";
102 }
103
104 if (!it->raw_key_is_prefixed(expected_prefix)) {
105 return ::testing::AssertionFailure()
106 << __func__
107 << " expected raw_key_is_prefixed() == TRUE"
108 << " got FALSE";
109 }
110
111 if (it->raw_key_is_prefixed("??__SomeUnexpectedValue__??")) {
112 return ::testing::AssertionFailure()
113 << __func__
114 << " expected raw_key_is_prefixed() == FALSE"
115 << " got TRUE";
116 }
117
118 pair<string,string> key = it->raw_key();
119
120 if (expected_prefix != key.first) {
121 return ::testing::AssertionFailure()
122 << __func__
123 << " expected prefix '" << expected_prefix << "'"
124 << " got prefix '" << key.first << "'";
125 }
126
127 if (expected_key != it->key()) {
128 return ::testing::AssertionFailure()
129 << __func__
130 << " expected key '" << expected_key << "'"
131 << " got key '" << it->key() << "'";
132 }
133
134 if (it->key() != key.second) {
135 return ::testing::AssertionFailure()
136 << __func__
137 << " key '" << it->key() << "'"
138 << " does not match"
139 << " pair key '" << key.second << "'";
140 }
141
142 if (_bl_to_str(it->value()) != expected_value) {
143 return ::testing::AssertionFailure()
144 << __func__
145 << " key '(" << key.first << "," << key.second << ")''"
146 << " expected value '" << expected_value << "'"
147 << " got value '" << _bl_to_str(it->value()) << "'";
148 }
149
150 return ::testing::AssertionSuccess();

Callers

nothing calls this directly

Calls 5

validMethod · 0.45
raw_key_is_prefixedMethod · 0.45
raw_keyMethod · 0.45
keyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected