use ifc_lite_processing::process_geometry;
const FIXTURE: &str = "../geometry/tests/fixtures/shared_point_faceted_brep.ifc";
const SHARED_POINTS: u64 = 196;
const PARTS: usize = 12;
fn fixture_path() -> std::path::PathBuf {
std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(FIXTURE)
}
#[test]
fn shared_point_faceted_breps_parse_each_point_once() {
let bytes = std::fs::read(fixture_path())
.expect("committed synthetic fixture shared_point_faceted_brep.ifc must be present");
let pool = rayon::ThreadPoolBuilder::new()
.num_threads(1)
.build()
.expect("build single-thread rayon pool");
let result = pool.install(|| process_geometry(&bytes));
assert_eq!(
result.stats.total_meshes, PARTS,
"expected {PARTS} faceted-brep meshes, got {}",
result.stats.total_meshes
);
let hits = result.stats.point_cache_hits;
let misses = result.stats.point_cache_misses;
assert_eq!(
misses, SHARED_POINTS,
"each shared CartesianPoint must be parsed exactly once across all parts \
(single-thread pool); got {misses} misses vs {SHARED_POINTS} shared points. \
A higher count means the per-worker point cache stopped memoizing across parts."
);
assert!(
hits > misses * 10,
"expected the shared pool to be re-referenced far more than parsed \
(hits={hits}, misses={misses})"
);
}