@@ -122,33 +122,6 @@ void test_uint40() {
122
122
}
123
123
}
124
124
125
- /* *
126
- * Tests the behavior of various move-constructors and move-assignment operators for the index.
127
- *
128
- * Constructs an index and performs tests with it before and after move operations to ensure that the index maintains
129
- * its integrity and functionality after being moved.
130
- *
131
- * @param config Configuration settings for the index.
132
- * @tparam index_at Type of the index being tested.
133
- */
134
- template <typename index_at> void test_move_constructors (index_config_t const & config) {
135
- {
136
- index_at index {config};
137
- test_sets (index );
138
- }
139
- {
140
- index_at index {config};
141
- index .reserve (1 );
142
- test_sets (index_at (std::move (index )));
143
- }
144
- {
145
- index_at index {config};
146
- index .reserve (1 );
147
- index_at index_moved = std::move (index );
148
- test_sets (index_moved);
149
- }
150
- }
151
-
152
125
/* *
153
126
* The goal of this test is to invoke as many different interfaces as possible, making sure that all code-paths compile.
154
127
* For that it only uses a tiny set of 3 predefined vectors.
@@ -199,15 +172,18 @@ void test_minimal_three_vectors(index_at& index, //
199
172
index .add (key_third, vector_third.data (), args...);
200
173
expect (index .size () == 3 );
201
174
202
- // Perform exact search
203
- matched_count = index .search (vector_first.data (), 5 , args...).dump_to (matched_keys, matched_distances);
175
+ // Perform single entry search
176
+ matched_count = index //
177
+ .search (vector_first.data (), 5 , args...) //
178
+ .dump_to (matched_keys, matched_distances);
204
179
expect (matched_count != 0 );
205
180
206
181
// Perform filtered exact search, keeping only odd values
207
182
if constexpr (punned_ak) {
208
183
auto is_odd = [](vector_key_t key) -> bool { return (key & 1 ) != 0 ; };
209
- matched_count =
210
- index .filtered_search (vector_first.data (), 5 , is_odd, args...).dump_to (matched_keys, matched_distances);
184
+ matched_count = index //
185
+ .filtered_search (vector_first.data (), 5 , is_odd, args...) //
186
+ .dump_to (matched_keys, matched_distances);
211
187
expect (matched_count != 0 );
212
188
for (std::size_t i = 0 ; i < matched_count; i++)
213
189
expect (is_odd (matched_keys[i]));
@@ -240,6 +216,50 @@ void test_minimal_three_vectors(index_at& index, //
240
216
241
217
index .save (" tmp.usearch" );
242
218
219
+ // Perform content and scan validations for a copy
220
+ {
221
+ auto copy_result = index .copy ();
222
+ expect (bool (copy_result));
223
+ auto & copied_index = copy_result.index ;
224
+
225
+ // Perform single entry search
226
+ matched_count = copied_index //
227
+ .search (vector_first.data (), 5 , args...) //
228
+ .dump_to (matched_keys, matched_distances);
229
+ expect (matched_count != 0 );
230
+
231
+ // Validate scans
232
+ std::size_t count = 0 ;
233
+ for (auto member : copied_index) {
234
+ vector_key_t id = member.key ;
235
+ expect (id >= key_first && id <= key_third);
236
+ count++;
237
+ }
238
+ expect ((count == 3 ));
239
+ expect ((copied_index.stats (0 ).nodes == 3 ));
240
+ }
241
+
242
+ // Perform content and scan validations for a moved
243
+ {
244
+ index_at moved_index (std::move (index ));
245
+
246
+ // Perform single entry search
247
+ matched_count = moved_index //
248
+ .search (vector_first.data (), 5 , args...) //
249
+ .dump_to (matched_keys, matched_distances);
250
+ expect (matched_count != 0 );
251
+
252
+ // Validate scans
253
+ std::size_t count = 0 ;
254
+ for (auto member : moved_index) {
255
+ vector_key_t id = member.key ;
256
+ expect (id >= key_first && id <= key_third);
257
+ count++;
258
+ }
259
+ expect ((count == 3 ));
260
+ expect ((moved_index.stats (0 ).nodes == 3 ));
261
+ }
262
+
243
263
// Check if metadata is retrieved correctly
244
264
if constexpr (punned_ak) {
245
265
auto head = index_dense_metadata_from_path (" tmp.usearch" );
0 commit comments