Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
neeleshpoli committed Dec 21, 2024
1 parent dd36013 commit fa7ecde
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion pumpkin-world/src/chunk/anvil.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ mod tests {
use pumpkin_core::math::vector2::Vector2;

use crate::{
chunk::{anvil::AnvilChunkReader, ChunkReader, ChunkReadingError},
chunk::{anvil::AnvilChunkReader, ChunkReader, ChunkReadingError, WorldInfo},
level::SaveFile,
};

Expand All @@ -234,4 +234,20 @@ mod tests {
);
assert!(matches!(result, Err(ChunkReadingError::ChunkNotExist)));
}

#[test]
fn test_level_dat_reading() {
let world_loader = AnvilChunkReader::new();
let root_folder = PathBuf::from("test-files").join("sample-1");
let save_file = SaveFile {
root_folder: root_folder.clone(),
region_folder: root_folder,
};
let expected = WorldInfo {
seed: -79717552349559436,
};
let info = world_loader.read_world_info(&save_file).unwrap();

assert_eq!(info, expected);
}
}
1 change: 1 addition & 0 deletions pumpkin-world/src/chunk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ pub enum ChunkParsingError {
ErrorDeserializingChunk(String),
}

#[derive(Debug, PartialEq)]
pub struct WorldInfo {
pub seed: i64,
// TODO: Implement all fields
Expand Down
Binary file added pumpkin-world/test-files/sample-1/level.dat
Binary file not shown.

0 comments on commit fa7ecde

Please sign in to comment.