Skip to content

Commit

Permalink
Update bitvec version and fix tests
Browse files Browse the repository at this point in the history
Bitvec changed byte order
  • Loading branch information
vaIgarashi committed Apr 14, 2020
1 parent 46c76b9 commit bbb8783
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ readme = "README.md"
[dependencies]
byteorder = "1.3"
named-binary-tag = "0.2"
bitvec = "0.15"
bitvec = "0.17"

[dev-dependencies]
tempfile = "3.1"
12 changes: 5 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,12 @@ impl AnvilRegion {

let chunks_metadata = Self::read_header(&mut file)?;
let total_sectors = file.metadata()?.len() as u32 / REGION_SECTOR_BYTES_LENGTH as u32;
let free_sectors = Self::used_sectors(total_sectors, &chunks_metadata);
let used_sectors = Self::used_sectors(total_sectors, &chunks_metadata);

let region = AnvilRegion {
file,
chunks_metadata,
used_sectors: free_sectors,
used_sectors,
};

Ok(region)
Expand Down Expand Up @@ -803,7 +803,7 @@ mod tests {

region.write_chunk(15, 15, write_compound_tag_2).unwrap();

assert_eq!(region.used_sectors.clone().into_vec()[0], 0b11011100);
assert_eq!(region.used_sectors.clone().into_vec()[0], 0b00111011);
assert_eq!(region.used_sectors.len(), 6);
assert_eq!(
file.as_file().metadata().unwrap().len(),
Expand All @@ -817,7 +817,7 @@ mod tests {
let used_sectors = AnvilRegion::used_sectors(8, &empty_chunks_metadata);

// Two sectors are used for header data.
assert_eq!(used_sectors.into_vec()[0], 0b11000000);
assert_eq!(used_sectors.into_vec()[0], 0b00000011);
}

#[test]
Expand All @@ -838,8 +838,6 @@ mod tests {
let used_sectors = AnvilRegion::used_sectors(10, &chunks_metadata);
let used_vec = used_sectors.into_vec();

assert_eq!(used_vec[0], 0b11011100);
assert_eq!(used_vec[1], 0b10000000);
assert_eq!(used_vec[0], 0b100111011);
}

}

0 comments on commit bbb8783

Please sign in to comment.