MCPcopy Create free account
hub / github.com/cactus-compute/cactus / test_query

Function test_query

tests/test_index.cpp:155–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

153}
154
155bool test_query() {
156 IndexFixture f("test_query");
157 if (!f.init()) return false;
158
159 auto target_emb = random_embedding();
160 f.add(1, "target", target_emb);
161 for (int i = 2; i <= 10; ++i) f.add(i, "other");
162
163 auto results = f.query(target_emb, 1);
164 if (results.empty() || results[0] != 1) return false;
165
166 f.del(1);
167 results = f.query(target_emb, 10);
168 for (int id : results) {
169 if (id == 1) return false;
170 }
171
172 return true;
173}
174
175bool test_compact() {
176 IndexFixture f("test_compact");

Callers 1

mainFunction · 0.85

Calls 5

random_embeddingFunction · 0.85
delMethod · 0.80
initMethod · 0.45
addMethod · 0.45
queryMethod · 0.45

Tested by

no test coverage detected