0.34.13_cleaup_code
This commit is contained in:
1 parent
ec46a96a29
commit
5c2e50ec06
87 files changed
+4890
-1338
No files matched your search
+28
-7
@@ -6,14 +6,32 @@ mod tests {
|
||||
assert_eq!(std::mem::size_of::<V6Range>(), 34);
|
||||
assert_eq!(std::mem::size_of::<V4Range>(), 12);
|
||||
let ranges = [
|
||||
V6Range { start: 0u128.to_be_bytes(), end: 127u128.to_be_bytes(), country: *b"PL" },
|
||||
V6Range { start: 256u128.to_be_bytes(), end: 65535u128.to_be_bytes(), country: *b"DE" },
|
||||
V6Range { start: (1u128 << 120).to_be_bytes(), end: u128::MAX.to_be_bytes(), country: *b"US" },
|
||||
V6Range {
|
||||
start: 0u128.to_be_bytes(),
|
||||
end: 127u128.to_be_bytes(),
|
||||
country: *b"PL",
|
||||
},
|
||||
V6Range {
|
||||
start: 256u128.to_be_bytes(),
|
||||
end: 65535u128.to_be_bytes(),
|
||||
country: *b"DE",
|
||||
},
|
||||
V6Range {
|
||||
start: (1u128 << 120).to_be_bytes(),
|
||||
end: u128::MAX.to_be_bytes(),
|
||||
country: *b"US",
|
||||
},
|
||||
];
|
||||
for (address, expected) in [
|
||||
(0, Some(*b"PL")), (127, Some(*b"PL")), (128, None),
|
||||
(255, None), (256, Some(*b"DE")), (65535, Some(*b"DE")),
|
||||
(65536, None), (1u128 << 120, Some(*b"US")), (u128::MAX, Some(*b"US")),
|
||||
(0, Some(*b"PL")),
|
||||
(127, Some(*b"PL")),
|
||||
(128, None),
|
||||
(255, None),
|
||||
(256, Some(*b"DE")),
|
||||
(65535, Some(*b"DE")),
|
||||
(65536, None),
|
||||
(1u128 << 120, Some(*b"US")),
|
||||
(u128::MAX, Some(*b"US")),
|
||||
] {
|
||||
assert_eq!(find_v6(&ranges, address.to_be_bytes()), expected);
|
||||
}
|
||||
@@ -33,7 +51,10 @@ mod tests {
|
||||
)
|
||||
.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_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