22 lines
705 B
Rust
22 lines
705 B
Rust
mod tests {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn range_lookup_handles_gaps() {
|
|
let directory = tempfile::tempdir().unwrap();
|
|
std::fs::write(
|
|
directory.path().join("user-country-ipv4.csv"),
|
|
"192.0.2.0,192.0.2.255,PL\n",
|
|
)
|
|
.unwrap();
|
|
std::fs::write(
|
|
directory.path().join("user-country-ipv6.csv"),
|
|
"2001:db8::,2001:db8::ffff,PL\n",
|
|
)
|
|
.unwrap();
|
|
let db = Database::load_format(directory.path(), DatabaseFormat::CsvPair).unwrap();
|
|
assert_eq!(db.country("192.0.2.7".parse().unwrap()).as_deref(), Some("PL"));
|
|
assert!(db.country("198.51.100.1".parse().unwrap()).is_none());
|
|
}
|
|
}
|