|
1 | 1 | // test_searcher.cpp — Unit tests for deglib::search::Searcher (searcher.h) |
2 | 2 |
|
3 | 3 | #include "deglib/builder.h" |
| 4 | +#include "deglib/deglib.h" |
4 | 5 | #include "deglib/distances.h" |
5 | 6 | #include "deglib/graph.h" |
6 | 7 | #include "deglib/optimization.h" |
@@ -47,6 +48,27 @@ TEST(SearcherTest, DirectFP32Search) { |
47 | 48 | EXPECT_NEAR(span_res.distances[0], 0.0f, 1e-5f); |
48 | 49 | } |
49 | 50 |
|
| 51 | +TEST(SearcherTest, MakeSearcherAcceptsFacade) { |
| 52 | + const uint32_t dim = 4; |
| 53 | + const uint32_t count = 20; |
| 54 | + |
| 55 | + std::vector<float> data(count * dim); |
| 56 | + for (size_t i = 0; i < data.size(); ++i) { |
| 57 | + data[i] = static_cast<float>(i * 1.5f + 0.1f); |
| 58 | + } |
| 59 | + |
| 60 | + auto graph = deglib::builder::build_from_data(std::span<const float>(data), dim, {}, 8, deglib::distances::Metric::FP32_L2); |
| 61 | + |
| 62 | + // The facade-level overload accepts a DynamicExplorationGraph directly (no .internal() bridge needed). |
| 63 | + auto searcher = deglib::make_searcher(graph); |
| 64 | + ASSERT_NE(searcher, nullptr); |
| 65 | + |
| 66 | + auto res = searcher->search(std::span<const float>(data.data(), dim), 5, 0.1f, 1.0f, /*return_distances=*/true); |
| 67 | + EXPECT_EQ(res.size(), 5u); |
| 68 | + EXPECT_EQ(res.indices[0], 0u); |
| 69 | + EXPECT_NEAR(res.distances[0], 0.0f, 1e-5f); |
| 70 | +} |
| 71 | + |
50 | 72 | TEST(SearcherTest, QuantizedInt8WithFP16Refiner) { |
51 | 73 | const uint32_t dim = 8; |
52 | 74 | const uint32_t count = 50; |
|
0 commit comments