#![allow(clippy::unwrap_used, clippy::expect_used, clippy::indexing_slicing)]
use super::*;
#[test]
fn a_published_example_key_is_recognized_and_names_where_it_came_from() {
let found = published_example(PUBLISHED_EXAMPLE_KEYS[0].public_key).expect("recognized");
assert!(found.provenance.contains("prikk docs/"));
}
#[test]
fn hex_case_is_not_part_of_the_value() {
let upper = PUBLISHED_EXAMPLE_KEYS[0].public_key.to_uppercase();
assert!(published_example(&upper).is_some());
assert!(published_example(&format!(" {upper} ")).is_some());
}
#[test]
fn an_ordinary_key_is_not_flagged() {
assert!(published_example(&"f".repeat(64)).is_none());
assert!(published_example("").is_none());
}
#[test]
fn every_entry_is_well_formed_and_sourced() {
assert_eq!(
PUBLISHED_EXAMPLE_KEYS.len(),
2,
"prikk 0.41.0 publishes exactly two example public keys in its user-facing docs; if that \
changed, re-run the sweep in this test's doc comment rather than adjusting the number"
);
for example in PUBLISHED_EXAMPLE_KEYS {
assert_eq!(example.public_key.len(), 64, "{example:?}");
assert!(
example
.public_key
.chars()
.all(|c| c.is_ascii_hexdigit() && !c.is_ascii_uppercase()),
"stored lowercase, as prikk prints it: {example:?}"
);
assert!(
example.provenance.contains("prikk ") && example.provenance.contains(':'),
"provenance must name a file and a line: {example:?}"
);
}
assert!(MEASURED_AT.contains("0.41.0"));
}