#![allow(clippy::unwrap_used)]
use timeglyph::scan;
#[test]
fn returns_the_whitespace_delimited_token_at_the_offset() {
let text = "created=1577836800 modified=1580000000";
assert_eq!(
scan::word_at(text, 10).as_deref(),
Some("created=1577836800")
);
assert_eq!(
scan::word_at(text, 25).as_deref(),
Some("modified=1580000000")
);
}
#[test]
fn returns_none_on_whitespace_or_out_of_range() {
let text = "abc 1577836800";
assert_eq!(scan::word_at(text, 3), None, "offset 3 is the space");
assert_eq!(scan::word_at(text, 999), None, "offset past the end");
}
#[test]
fn maps_utf16_offsets_past_non_bmp_characters() {
let text = "🕐 1577836800";
assert_eq!(scan::word_at(text, 3).as_deref(), Some("1577836800"));
assert_eq!(scan::word_at(text, 4).as_deref(), Some("1577836800"));
}