use super::Sighting;
#[test]
fn a_sighting_carries_the_evidence_the_term_it_added_and_the_rank_behind_it() {
let seen = Sighting::new(0.25, 3, "transcript");
assert!((seen.contribution() - 0.25).abs() < f64::EPSILON);
assert_eq!(seen.ordinal(), 3);
assert_eq!(seen.seen(), &"transcript");
assert_eq!(seen.into_components(), (0.25, 3, "transcript"));
}
#[test]
fn mapping_the_evidence_leaves_the_contribution_where_the_fold_put_it() {
let mapped = Sighting::new(0.125, 7, 3_u32).map_seen(|rank| rank.to_string());
assert!((mapped.contribution() - 0.125).abs() < f64::EPSILON);
assert_eq!(
mapped.ordinal(),
7,
"the map dropped the rank the fold carried"
);
assert_eq!(mapped.seen(), "3");
}
#[test]
fn two_currencies_contribute_in_one_arithmetic() {
let deep: Sighting<f64> = Sighting::new(0.5, 1, 0.98_f64);
let shallow: Sighting<f32> = Sighting::new(0.25, 2, 0.31_f32);
assert!(deep.contribution() > shallow.contribution());
}
#[test]
fn the_rank_cannot_be_run_backwards_out_of_the_term_it_produced() {
let heavy = Sighting::new(2.0 / 61.0, 1, "shots");
let light = Sighting::new(0.5 / 61.0, 1, "subs");
assert_eq!(heavy.ordinal(), light.ordinal(), "one rank, two beliefs");
assert!(
heavy.contribution() > light.contribution(),
"the weight is what separates them, and it is not on the wire",
);
}