use super::{asked, participates};
#[test]
fn a_routes_own_question_beats_the_tiers_and_the_parents() {
assert_eq!(
asked(Some("sunset"), Some("harbour"), Some("dusk")),
Some("sunset"),
);
}
#[test]
fn a_silent_route_takes_the_tiers_question() {
assert_eq!(asked(None, Some("harbour"), Some("dusk")), Some("harbour"));
}
#[test]
fn a_silent_tier_passes_the_parents_question_down() {
assert_eq!(asked(None, None, Some("dusk")), Some("dusk"));
}
#[test]
fn a_chain_nobody_answered_resolves_to_nothing() {
assert_eq!(asked::<str>(None, None, None), None);
}
#[test]
fn the_winner_is_borrowed_and_never_copied() {
let own = vec![0.5_f32, 0.25];
let parent = vec![0.0_f32];
let resolved = asked(Some(own.as_slice()), None, Some(parent.as_slice()))
.expect("the route named its own coordinates");
assert!(
core::ptr::eq(resolved, own.as_slice()),
"the resolution handed back the caller's own slice",
);
}
#[test]
fn two_routes_of_two_currencies_resolve_independently() {
let coordinates = [0.5_f32, 0.5];
let text = asked(None, None, Some("harbour at dusk"));
let vector = asked(Some(coordinates.as_slice()), None, None);
assert_eq!(text, Some("harbour at dusk"));
assert_eq!(vector, Some(coordinates.as_slice()));
}
#[test]
fn a_route_enters_only_when_it_is_walked_and_answerable() {
assert!(participates(true, Some("sunset")));
assert!(
!participates(false, Some("sunset")),
"a disabled edge does not enter however answerable it is",
);
assert!(
!participates::<str>(true, None),
"an unanswerable route does not enter however enabled it is",
);
assert!(!participates::<str>(false, None));
}