Skip to content

Commit

Permalink
tests: add tests for wire signal strength
Browse files Browse the repository at this point in the history
  • Loading branch information
StackDoubleFlow committed Jan 26, 2025
1 parent c8655b0 commit 5a014da
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,45 @@ fn repeater_on_off(backend: TestBackend) {
runner.check_block_powered(trapdoor_pos, false);
}
}

test_all_backends!(wire_barely_reaches);
fn wire_barely_reaches(backend: TestBackend) {
let lever_pos = pos(0, 1, 0);
let trapdoor_pos = pos(16, 1, 0);

let mut world = TestWorld::new(2);
make_lever(&mut world, lever_pos);
// 15 wire blocks between lever and trapdoor
for x in 1..=15 {
make_wire(&mut world, pos(x, 1, 0));
}
world.set_block(trapdoor_pos, trapdoor());

let mut runner = BackendRunner::new(world, backend);
runner.check_block_powered(trapdoor_pos, false);
runner.use_block(lever_pos);
runner.check_block_powered(trapdoor_pos, true);
runner.use_block(lever_pos);
runner.check_block_powered(trapdoor_pos, false);
}

test_all_backends!(wire_no_reach);
fn wire_no_reach(backend: TestBackend) {
let lever_pos = pos(0, 1, 0);
let trapdoor_pos = pos(17, 1, 0);

let mut world = TestWorld::new(2);
make_lever(&mut world, lever_pos);
// 16 wire blocks between lever and trapdoor
for x in 1..=16 {
make_wire(&mut world, pos(x, 1, 0));
}
world.set_block(trapdoor_pos, trapdoor());

let mut runner = BackendRunner::new(world, backend);
runner.check_block_powered(trapdoor_pos, false);
runner.use_block(lever_pos);
runner.check_block_powered(trapdoor_pos, false);
runner.use_block(lever_pos);
runner.check_block_powered(trapdoor_pos, false);
}

0 comments on commit 5a014da

Please sign in to comment.