use super::*;
use crate::registry::multi_vector;
use crate::registry::rerank;
use crate::registry::sparse::SparseComputation;
use crate::registry::sparse::all as sparse_entries;
fn cells(rows: &DtypeBackendSupport) -> Vec<Support> {
[rows.f32, rows.f16, rows.bf16]
.iter()
.flat_map(|row| [row.cpu, row.metal, row.cuda])
.collect()
}
#[test]
fn every_registered_entry_in_every_catalog_carries_a_verified_cell() {
let computed: Vec<String> = sparse_entries()
.into_iter()
.filter(|d| d.computation == SparseComputation::Computed)
.map(|d| d.id)
.collect();
assert_eq!(computed, ["Qdrant/bm25"]);
let catalogs: [(&str, Vec<(String, DtypeBackendSupport)>); 4] = [
(
"dense",
all()
.into_iter()
.map(|d| (d.id, d.dtype_backends))
.collect(),
),
(
"sparse",
sparse_entries()
.into_iter()
.map(|d| (d.id, d.dtype_backends))
.collect(),
),
(
"multi-vector",
multi_vector::all()
.into_iter()
.map(|d| (d.id, d.dtype_backends))
.collect(),
),
(
"rerank",
rerank::all()
.into_iter()
.map(|d| (d.id, d.dtype_backends))
.collect(),
),
];
for (catalog, entries) in catalogs {
assert!(!entries.is_empty(), "the {catalog} catalog is empty");
for (id, rows) in entries {
let cells = cells(&rows);
if computed.contains(&id) {
assert!(
cells.iter().all(|&cell| cell == Support::NotApplicable),
"{catalog} {id}: a computed entry has no device or dtype axis, so every cell is not_applicable: {rows:?}"
);
continue;
}
assert!(
cells.contains(&Support::Verified),
"{catalog} {id}: registered with no verified cell; an entry lands only once a golden run verifies one: {rows:?}"
);
}
}
}