#![cfg(feature = "full")]
use oxgraph::{
csr::CsrSnapshotIndex,
hyper_bcsr::BcsrSnapshotIndex,
postgres::{
SNAPSHOT_KIND_PG_CATALOG, SNAPSHOT_KIND_PG_INBOUND_OFFSETS_U32,
SNAPSHOT_KIND_PG_INBOUND_TARGETS_U32, SNAPSHOT_KIND_PG_METADATA,
},
property::PropertySnapshotMetaWord,
};
macro_rules! widths {
($trait:ident :: $kind:ident) => {
[
<u16 as $trait>::$kind,
<u32 as $trait>::$kind,
<u64 as $trait>::$kind,
]
};
}
const DATABASE_KIND_COUNT: u32 = 22;
fn all_registry_kinds() -> Vec<u32> {
let mut kinds = Vec::new();
kinds.extend(widths!(CsrSnapshotIndex::OFFSETS_KIND));
kinds.extend(widths!(CsrSnapshotIndex::TARGETS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::HEAD_OFFSETS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::HEAD_PARTICIPANTS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::TAIL_OFFSETS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::TAIL_PARTICIPANTS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::VERTEX_OUTGOING_OFFSETS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::VERTEX_OUTGOING_HYPEREDGES_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::VERTEX_INCOMING_OFFSETS_KIND));
kinds.extend(widths!(BcsrSnapshotIndex::VERTEX_INCOMING_HYPEREDGES_KIND));
kinds.extend(widths!(PropertySnapshotMetaWord::PROPERTY_DESCRIPTORS_KIND));
kinds.extend(widths!(PropertySnapshotMetaWord::PROPERTY_DATA_KIND));
kinds.extend(widths!(PropertySnapshotMetaWord::IDENTITY_MODES_KIND));
kinds.extend(widths!(PropertySnapshotMetaWord::ELEMENT_IDENTITY_MAP_KIND));
kinds.extend(widths!(
PropertySnapshotMetaWord::RELATION_IDENTITY_MAP_KIND
));
kinds.extend(widths!(
PropertySnapshotMetaWord::INCIDENCE_IDENTITY_MAP_KIND
));
kinds.extend([
SNAPSHOT_KIND_PG_CATALOG,
SNAPSHOT_KIND_PG_INBOUND_OFFSETS_U32,
SNAPSHOT_KIND_PG_INBOUND_TARGETS_U32,
SNAPSHOT_KIND_PG_METADATA,
]);
kinds.extend((0..DATABASE_KIND_COUNT).map(|offset| 0x0300 + offset));
kinds
}
#[test]
fn registry_kinds_are_pairwise_distinct() {
let kinds = all_registry_kinds();
let mut sorted = kinds.clone();
sorted.sort_unstable();
for window in sorted.windows(2) {
assert_ne!(
window[0], window[1],
"duplicate section kind {:#06X} in the registry",
window[0],
);
}
assert_eq!(kinds.len(), 74, "registry table lost or gained an entry");
}