use super::cargo::emit_cargo_toml;
use crate::core::ir::ApiSurface;
#[test]
fn cargo_toml_forwards_excluded_feature_not_referenced_by_any_cfg_attribute() {
let api = ApiSurface::default();
let content = emit_cargo_toml(
"sample-lib",
"sample_lib",
"sample-lib",
"0.1.0",
"0.1.0",
"0.1.0",
"../..",
&[],
"",
"MIT",
false,
&[],
&api,
&["heic".to_string()],
"sample-lib-ffi",
"../../../crates/sample-lib-ffi",
&[],
&[],
&Default::default(),
);
assert!(
content.contains("[features]"),
"a config-only excluded_default_features name must still produce a [features] table:\n{content}"
);
assert!(
content.contains(r#"heic = ["sample_lib/heic"]"#),
"a config-only excluded_default_features name (not referenced by any #[cfg(feature = ...)] \
in the API surface) must still get a forwarding entry so `cargo build --features heic` \
keeps working:\n{content}"
);
let default_line = content
.lines()
.find(|l| l.starts_with("default = ["))
.expect("default = [...] line must be emitted");
assert!(
!default_line.contains("\"heic\""),
"default = [...] must NOT contain excluded `heic`; got: {default_line}"
);
toml::from_str::<toml::Value>(&content).expect("generated Cargo.toml must be valid TOML");
}