test: cover deterministic HashMap ordering paths
This commit is contained in:
parent
58bb9fa9a7
commit
13ee9e6398
2 changed files with 73 additions and 0 deletions
|
|
@ -1452,4 +1452,37 @@ mod tests {
|
|||
);
|
||||
assert_eq!(identity.psychology.unwrap().mbti.as_deref(), Some("ENTP"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn aieos_to_system_prompt_sorts_hashmap_sections_for_determinism() {
|
||||
let mut neural_matrix = std::collections::HashMap::new();
|
||||
neural_matrix.insert("zeta".to_string(), 0.10);
|
||||
neural_matrix.insert("alpha".to_string(), 0.90);
|
||||
|
||||
let mut favorites = std::collections::HashMap::new();
|
||||
favorites.insert("snack".to_string(), "tea".to_string());
|
||||
favorites.insert("book".to_string(), "rust".to_string());
|
||||
|
||||
let identity = AieosIdentity {
|
||||
psychology: Some(PsychologySection {
|
||||
neural_matrix: Some(neural_matrix),
|
||||
..Default::default()
|
||||
}),
|
||||
interests: Some(InterestsSection {
|
||||
favorites: Some(favorites),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let prompt = aieos_to_system_prompt(&identity);
|
||||
|
||||
let alpha_pos = prompt.find("- alpha: 0.90").unwrap();
|
||||
let zeta_pos = prompt.find("- zeta: 0.10").unwrap();
|
||||
assert!(alpha_pos < zeta_pos);
|
||||
|
||||
let book_pos = prompt.find("- book: rust").unwrap();
|
||||
let snack_pos = prompt.find("- snack: tea").unwrap();
|
||||
assert!(book_pos < snack_pos);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue