Skip to content

Commit b1ca345

Browse files
committed
blocks: add unit tests for #467 #469 #474
1 parent eae327a commit b1ca345

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

blocks/src/lib.rs

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5788,6 +5788,100 @@ define_blocks! {
57885788
}
57895789
}
57905790

5791+
#[cfg(test)]
5792+
mod tests {
5793+
use super::*;
5794+
5795+
// Spot check a few blocks across different versions, including the correctly recognized last supported block
5796+
// TODO: comprehensive testing against https://github.com/PrismarineJS/minecraft-data/tree/master/data/pc
5797+
5798+
#[test]
5799+
fn hier_1_12_2() {
5800+
let id_map = VanillaIDMap::new(340);
5801+
assert_eq!(
5802+
id_map.by_vanilla_id(255 << 4, &HashMap::new()),
5803+
StructureBlock {
5804+
mode: StructureBlockMode::Save
5805+
}
5806+
);
5807+
assert_eq!(
5808+
id_map.by_vanilla_id((255 << 4) | 3, &HashMap::new()),
5809+
StructureBlock {
5810+
mode: StructureBlockMode::Data
5811+
}
5812+
);
5813+
}
5814+
5815+
#[test]
5816+
fn flat_1_13_2() {
5817+
let id_map = VanillaIDMap::new(404);
5818+
assert_eq!(
5819+
id_map.by_vanilla_id(8595, &HashMap::new()),
5820+
StructureBlock {
5821+
mode: StructureBlockMode::Save
5822+
}
5823+
);
5824+
assert_eq!(
5825+
id_map.by_vanilla_id(8598, &HashMap::new()),
5826+
StructureBlock {
5827+
mode: StructureBlockMode::Data
5828+
}
5829+
);
5830+
}
5831+
5832+
#[test]
5833+
fn flat_1_14_4() {
5834+
let id_map = VanillaIDMap::new(477);
5835+
assert_eq!(
5836+
id_map.by_vanilla_id(9113, &HashMap::new()),
5837+
Conduit { waterlogged: true }
5838+
);
5839+
assert_eq!(
5840+
id_map.by_vanilla_id(9114, &HashMap::new()),
5841+
Conduit { waterlogged: false }
5842+
);
5843+
}
5844+
5845+
#[test]
5846+
fn flat_1_15_1() {
5847+
let id_map = VanillaIDMap::new(575);
5848+
assert_eq!(
5849+
id_map.by_vanilla_id(9113, &HashMap::new()),
5850+
Conduit { waterlogged: true }
5851+
);
5852+
assert_eq!(
5853+
id_map.by_vanilla_id(9114, &HashMap::new()),
5854+
Conduit { waterlogged: false }
5855+
);
5856+
}
5857+
5858+
#[test]
5859+
fn flat_1_16() {
5860+
let id_map = VanillaIDMap::new(735);
5861+
assert_eq!(
5862+
id_map.by_vanilla_id(1048, &HashMap::new()),
5863+
NoteBlock {
5864+
instrument: NoteBlockInstrument::Pling,
5865+
note: 24,
5866+
powered: false
5867+
}
5868+
);
5869+
}
5870+
5871+
#[test]
5872+
fn flat_1_16_2() {
5873+
let id_map = VanillaIDMap::new(751);
5874+
assert_eq!(
5875+
id_map.by_vanilla_id(1048, &HashMap::new()),
5876+
NoteBlock {
5877+
instrument: NoteBlockInstrument::Pling,
5878+
note: 24,
5879+
powered: false
5880+
}
5881+
);
5882+
}
5883+
}
5884+
57915885
fn can_burn<W: WorldAccess>(world: &W, pos: Position) -> bool {
57925886
matches!(world.get_block(pos), Block::Planks { .. }
57935887
| Block::DoubleWoodenSlab { .. }

0 commit comments

Comments
 (0)