use super::*;
#[test]
fn building_elements_have_geometry() {
for name in [
"IFCWALL",
"IFCSLAB",
"IFCBEAM",
"IFCCOLUMN",
"IFCDOOR",
"IFCWINDOW",
"IFCROOF",
"IFCSTAIR",
"IFCSHADINGDEVICE",
] {
assert!(has_geometry_by_name(name), "{name} should have geometry");
}
}
#[test]
fn mep_elements_have_geometry() {
for name in [
"IFCFLOWSEGMENT",
"IFCFLOWFITTING",
"IFCENERGYCONVERSIONDEVICE",
"IFCFLOWTREATMENTDEVICE",
"IFCBOILER",
"IFCPUMP",
"IFCVALVE",
] {
assert!(has_geometry_by_name(name), "{name} should have geometry");
}
}
#[test]
fn solar_device_has_geometry() {
assert!(has_geometry_by_name("IFCSOLARDEVICE"));
assert!(has_geometry_by_name("IfcSolarDevice"));
}
#[test]
fn ifc4x3_infrastructure_have_geometry() {
for name in [
"IFCBEARING",
"IFCKERB",
"IFCPAVEMENT",
"IFCRAIL",
"IFCTRACKELEMENT",
"IFCSIGN",
"IFCSIGNAL",
"IFCEARTHWORKSCUT",
] {
assert!(has_geometry_by_name(name), "{name} should have geometry");
}
}
#[test]
fn reinforcement_variants_have_geometry() {
assert!(has_geometry_by_name("IFCREINFORCINGBAR"));
assert!(has_geometry_by_name("IFCREINFORCINGMESH"));
assert!(has_geometry_by_name("IFCREINFORCEDSOIL"));
}
#[test]
fn standardcase_and_elementedcase_have_geometry() {
for name in [
"IFCBEAMSTANDARDCASE",
"IFCSLABSTANDARDCASE",
"IFCSLABELEMENTEDCASE",
"IFCWALLSTANDARDCASE",
"IFCWALLELEMENTEDCASE",
"IFCDOORSTANDARDCASE",
"IFCWINDOWSTANDARDCASE",
"IFCOPENINGSTANDARDCASE",
] {
assert!(has_geometry_by_name(name), "{name} should have geometry");
}
}
#[test]
fn space_and_site_have_geometry() {
assert!(has_geometry_by_name("IFCSPACE"));
assert!(has_geometry_by_name("IFCSITE"));
assert!(has_geometry_by_name("IFCOPENINGELEMENT"));
assert!(has_geometry_by_name("IFCSPATIALZONE"));
}
#[test]
fn building_bears_geometry() {
assert!(has_geometry_by_name("IFCBUILDING"));
assert!(has_geometry_by_name("IfcBuilding"));
assert!(!has_geometry_by_name("IFCBUILDINGSTOREY"));
assert!(!has_geometry_by_name("IFCFACILITY"));
}
#[test]
fn legacy_ifc2x3_distribution_names_have_geometry() {
assert!(has_geometry_by_name("IFCEQUIPMENTELEMENT"));
assert!(has_geometry_by_name("IFCELECTRICALDISTRIBUTIONPOINT"));
}
#[test]
fn non_geometric_spatial_excluded() {
for name in [
"IFCBUILDINGSTOREY",
"IFCFACILITY",
"IFCFACILITYPART",
"IFCSPATIALELEMENT",
"IFCSPATIALSTRUCTUREELEMENT",
"IFCBRIDGE",
"IFCROAD",
"IFCRAILWAY",
"IFCMARINEFACILITY",
"IFCBRIDGEPART",
"IFCFACILITYPARTCOMMON",
"IFCEXTERNALSPATIALELEMENT",
"IFCEXTERNALSPATIALSTRUCTUREELEMENT",
] {
assert!(!has_geometry_by_name(name), "{name} should NOT have geometry");
}
}
#[test]
fn non_products_excluded() {
for name in [
"IFCPROJECT",
"IFCMATERIAL",
"IFCPROPERTYSET",
"IFCRELAGGREGATES",
"IFCDIMENSIONALEXPONENTS",
"IFCSURFACESTYLERENDERING",
"IFCGEOMETRICREPRESENTATIONSUBCONTEXT",
"IFCCARTESIANPOINT",
] {
assert!(!has_geometry_by_name(name), "{name} should NOT have geometry");
}
}
#[test]
fn legacy_proxy_and_buildingelement_have_geometry() {
assert!(has_geometry_by_name("IFCPROXY"));
assert!(has_geometry_by_name("IFCBUILDINGELEMENT"));
}
#[test]
fn unknown_garbage_excluded() {
assert!(!has_geometry_by_name("IFCNOTAREALTYPE"));
assert!(!has_geometry_by_name(""));
assert!(!has_geometry_by_name("FOOREINFORCEDBAR"));
}
#[test]
fn cached_results_are_consistent() {
for _ in 0..3 {
assert!(has_geometry_by_name("IFCWALL"));
assert!(!has_geometry_by_name("IFCPROJECT"));
assert!(is_simple_geometry_type("IFCWALL"));
assert!(!is_simple_geometry_type("IFCWINDOW"));
}
}
#[test]
fn is_simple_geometry_type_routes_correctly() {
assert!(is_simple_geometry_type("IFCWALL"));
assert!(is_simple_geometry_type("IFCSLAB"));
assert!(is_simple_geometry_type("IFCBEAM"));
assert!(is_simple_geometry_type("IFCCOLUMN"));
assert!(!is_simple_geometry_type("IFCWINDOW"));
assert!(!is_simple_geometry_type("IFCDOOR"));
assert!(!is_simple_geometry_type("IFCOPENINGELEMENT"));
assert!(!is_simple_geometry_type("IFCFLOWSEGMENT"));
assert!(!is_simple_geometry_type("IFCSOLARDEVICE"));
assert!(!is_simple_geometry_type("IFCSPACE"));
assert!(!is_simple_geometry_type("IFCANNOTATION"));
assert!(!is_simple_geometry_type("IFCBUILDINGELEMENTPROXY"));
assert!(is_simple_geometry_type("IfcWall"));
assert!(!is_simple_geometry_type("IfcDoor"));
}
#[test]
fn nth_attribute_present_and_non_null_is_true() {
let entity = b"#40=IFCBUILDINGSTOREY('guid',$,'Level 1',$,$,#18,#39,$,.ELEMENT.,0.);";
assert!(nth_attribute_is_present(entity, 0));
assert!(nth_attribute_is_present(entity, 6));
}
#[test]
fn nth_attribute_dollar_is_false() {
let entity = b"#40=IFCBUILDINGSTOREY('guid',$,'Level 1',$,$,#18,$,$,.ELEMENT.,0.);";
assert!(!nth_attribute_is_present(entity, 6));
assert!(!nth_attribute_is_present(entity, 1));
}
#[test]
fn nth_attribute_past_the_end_is_false() {
let entity = b"#1=IFCWALL('guid',$,'Wall');";
assert!(!nth_attribute_is_present(entity, 10));
}
#[test]
fn nth_attribute_empty_value_is_false() {
let entity = b"#1=IFCFOO('a',,'c');";
assert!(!nth_attribute_is_present(entity, 1));
assert!(nth_attribute_is_present(entity, 0));
assert!(nth_attribute_is_present(entity, 2));
}
#[test]
fn nth_attribute_nested_parens_are_not_top_level_commas() {
let entity = b"#30=IFCPOLYLOOP((#20,#21,#22),$);";
assert!(nth_attribute_is_present(entity, 0));
assert!(!nth_attribute_is_present(entity, 1));
assert!(!nth_attribute_is_present(entity, 2));
}
#[test]
fn nth_attribute_quoted_comma_and_paren_are_not_top_level() {
let entity =
b"#40=IFCBUILDINGSTOREY('guid',$,'Level 1, west (annex)',$);";
assert!(nth_attribute_is_present(entity, 0)); assert!(!nth_attribute_is_present(entity, 1)); assert!(nth_attribute_is_present(entity, 2)); assert!(!nth_attribute_is_present(entity, 3)); assert!(!nth_attribute_is_present(entity, 4));
}
#[test]
fn nth_attribute_escaped_quote_stays_inside_the_string() {
let entity = b"#1=IFCWALL('guid',$,'quo''te',$);";
assert!(nth_attribute_is_present(entity, 2)); assert!(!nth_attribute_is_present(entity, 3)); assert!(!nth_attribute_is_present(entity, 4));
}
#[test]
fn nth_attribute_no_open_paren_is_false() {
assert!(!nth_attribute_is_present(b"#1=IFCWALL;", 0));
}
#[test]
fn nth_attribute_no_close_paren_is_false() {
assert!(!nth_attribute_is_present(b"#1=IFCWALL('guid'", 0));
}
#[test]
fn nth_attribute_reversed_boundary_is_false() {
assert!(!nth_attribute_is_present(b")(", 0));
assert!(!nth_attribute_is_present(b"garbage)stuff(more", 0));
}