v0.28.0
This commit is contained in:
1 parent
c24bc4279b
commit
3b3f0db377
84 files changed
+2686
-392
No files matched your search
+14
-12
@@ -1,19 +1,21 @@
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn range_lookup_handles_gaps() {
|
||||
let db = Database {
|
||||
ipv4: vec![V4Range {
|
||||
start: u32::from(Ipv4Addr::new(192, 0, 2, 0)),
|
||||
end: u32::from(Ipv4Addr::new(192, 0, 2, 255)),
|
||||
country: *b"PL",
|
||||
}],
|
||||
ipv6: vec![],
|
||||
};
|
||||
assert_eq!(
|
||||
db.country("192.0.2.7".parse().unwrap()).as_deref(),
|
||||
Some("PL")
|
||||
);
|
||||
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());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user