blocks: add unit tests for #467 #469 #474

This commit is contained in:
ice_iix 2021-01-20 16:51:18 -08:00
parent eae327acb2
commit b1ca345a7b
1 changed files with 94 additions and 0 deletions

View File

@ -5788,6 +5788,100 @@ define_blocks! {
}
}
#[cfg(test)]
mod tests {
use super::*;
// Spot check a few blocks across different versions, including the correctly recognized last supported block
// TODO: comprehensive testing against https://github.com/PrismarineJS/minecraft-data/tree/master/data/pc
#[test]
fn hier_1_12_2() {
let id_map = VanillaIDMap::new(340);
assert_eq!(
id_map.by_vanilla_id(255 << 4, &HashMap::new()),
StructureBlock {
mode: StructureBlockMode::Save
}
);
assert_eq!(
id_map.by_vanilla_id((255 << 4) | 3, &HashMap::new()),
StructureBlock {
mode: StructureBlockMode::Data
}
);
}
#[test]
fn flat_1_13_2() {
let id_map = VanillaIDMap::new(404);
assert_eq!(
id_map.by_vanilla_id(8595, &HashMap::new()),
StructureBlock {
mode: StructureBlockMode::Save
}
);
assert_eq!(
id_map.by_vanilla_id(8598, &HashMap::new()),
StructureBlock {
mode: StructureBlockMode::Data
}
);
}
#[test]
fn flat_1_14_4() {
let id_map = VanillaIDMap::new(477);
assert_eq!(
id_map.by_vanilla_id(9113, &HashMap::new()),
Conduit { waterlogged: true }
);
assert_eq!(
id_map.by_vanilla_id(9114, &HashMap::new()),
Conduit { waterlogged: false }
);
}
#[test]
fn flat_1_15_1() {
let id_map = VanillaIDMap::new(575);
assert_eq!(
id_map.by_vanilla_id(9113, &HashMap::new()),
Conduit { waterlogged: true }
);
assert_eq!(
id_map.by_vanilla_id(9114, &HashMap::new()),
Conduit { waterlogged: false }
);
}
#[test]
fn flat_1_16() {
let id_map = VanillaIDMap::new(735);
assert_eq!(
id_map.by_vanilla_id(1048, &HashMap::new()),
NoteBlock {
instrument: NoteBlockInstrument::Pling,
note: 24,
powered: false
}
);
}
#[test]
fn flat_1_16_2() {
let id_map = VanillaIDMap::new(751);
assert_eq!(
id_map.by_vanilla_id(1048, &HashMap::new()),
NoteBlock {
instrument: NoteBlockInstrument::Pling,
note: 24,
powered: false
}
);
}
}
fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
matches!(world.get_block(pos), Block::Planks { .. }
| Block::DoubleWoodenSlab { .. }