Fix words bug

This commit is contained in:
Austen Adler 2023-02-22 23:19:35 -05:00
parent d8e4fe96fd
commit f5211589e8
5 changed files with 11062 additions and 11014 deletions

File diff suppressed because it is too large Load Diff

View File

@ -172,8 +172,6 @@ impl Address<'_> {
// Add the 1 bit at position 14
ret = ret | (0b1 << 14);
dbg!(ret);
Ok(CellID(ret))
}
ver => Err(Error::InvalidVersion(ver)),

View File

@ -1,5 +1,6 @@
use crate::{conversions, Address};
use std::ops::RangeInclusive;
use words::NUMBER_TO_WORDS;
use s2::{cell::Cell, cellid::CellID};
@ -33,7 +34,7 @@ impl From<UnpackedCellID> for Address<'_> {
eprintln!(
"Got number: for word 0: {} (of {})",
unpacked_cell_id.word0_bits as usize,
words::NUMBER_TO_WORDS.len()
NUMBER_TO_WORDS.len()
);
let word0 = words::NUMBER_TO_WORDS[unpacked_cell_id.word0_bits as usize][0];
let word1 = words::NUMBER_TO_WORDS[unpacked_cell_id.word1_bits as usize][0];

View File

@ -22,7 +22,7 @@ fn test_cellid_translation() {
let addr_cellid = addr.as_cell_id().unwrap();
// Make sure the address is at the right level
assert_eq_u64!(addr_cellid.level(), CELLID_LEVEL as u64);
assert_eq!(addr_cellid.level(), CELLID_LEVEL as u64);
// Next, check if creating an address from a cellid matches itself
assert_eq!(addr, Address::from_cellid_u64(entry.cell_id));

View File

@ -60,11 +60,14 @@ mod tests {
#[test]
fn test_length() {
assert!(WORDS.len() > 8195);
assert!(WORDS.len() >= 8195);
assert!(NUMBER_TO_WORDS.len() >= 8195);
for i in 0..8195_u16 {
assert_eq!(NUMBER_TO_WORDS[i as usize][0].number, i);
}
assert!(false);
}
#[test]