-
-
Save slaperche-zenly/2b28b2139de2b27f68a1780c71bf694a to your computer and use it in GitHub Desktop.
Check on a few billions values that the optimised version of h3IsValid returns the same result as the reference implementation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn main() { | |
let mut valid = 0; | |
let mut invalid = 0; | |
for i in 0..=0x7fff_ffff_u32 { | |
let cell = 0x0880_0000_001f_ffff | (u64::from(i) << 21); | |
let result = h3cell::is_valid_h3(cell); | |
let expected = unsafe { h3ron_h3_sys::h3IsValid(cell) != 0 }; | |
valid += expected as usize; | |
invalid += !expected as usize; | |
assert_eq!( | |
result, expected, | |
"{}: sanic={}, h3ron={}", | |
cell, result, expected | |
); | |
if i % 1_000_000 == 0 { | |
eprintln!("{}/{}", i, 0x7fff_ffff); | |
} | |
} | |
println!("{} valid, {} invalid", valid, invalid); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment