test(engine): retain static schema names across shared factor rows

This commit is contained in:
boris
2026-09-13 13:07:51 +08:00
committed by boris
parent 93809eea1b
commit 2286bfa757
2 changed files with 23 additions and 3 deletions
+13
View File
@@ -436,6 +436,19 @@ mod tests {
assert!(rows.iter().all(|row| matches!(row.storage, Storage::Owned(_))));
}
#[test]
fn shared_schema_borrows_a_static_key_even_after_a_dynamic_equal_key() {
const KEY: &str = "a_shared_factor_name_longer_than_inline_storage";
let mut rows = (0..64).map(|index| NumericFactorMap::from([
(if index == 0 { Cow::Owned(KEY.to_string()) } else { Cow::Borrowed(KEY) }, index as f64),
(Cow::Borrowed("another"), 2.0),
])).collect::<Vec<_>>();
assert_eq!(NumericFactorMap::share_rows(rows.iter_mut()), rows.len());
for row in &rows {
assert_eq!(row.keys().find(|key| key.as_str() == KEY).unwrap().as_static_str(), Some(KEY));
}
}
#[test]
fn compact_keys_inline_dynamic_names_and_keep_long_static_storage() {
const LONG: &str = "a_long_static_factor_identifier_that_must_remain_borrowed";