MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / test_unit_disintegrate

Function test_unit_disintegrate

battlecode-engine/src/world.rs:2582–2600  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2580
2581 #[test]
2582 fn test_unit_disintegrate() {
2583 let mut world = GameWorld::test_world();
2584 let loc_a = MapLocation::new(Planet::Earth, 0, 1);
2585 let loc_b = MapLocation::new(Planet::Earth, 0, 2);
2586 let id_a = world.create_unit(Team::Red, loc_a, UnitType::Knight).unwrap();
2587 let id_b = world.create_unit(Team::Blue, loc_b, UnitType::Knight).unwrap();
2588
2589 // Red can disintegrate a red unit.
2590 assert!(world.disintegrate_unit(id_a).is_ok());
2591
2592 // Red cannot disintegrate a blue unit.
2593 assert_err!(world.disintegrate_unit(id_b), GameError::TeamNotAllowed);
2594
2595 // But the Dev engine can "destroy" a blue unit if necessary.
2596 world.destroy_unit(id_b);
2597
2598 // Either way, no one can disintegrate a unit that does not exist.
2599 assert_err!(world.disintegrate_unit(id_b), GameError::NoSuchUnit);
2600 }
2601
2602 #[test]
2603 fn test_unit_destroy_with_filter() {

Callers

nothing calls this directly

Calls 2

create_unitMethod · 0.80
destroy_unitMethod · 0.80

Tested by

no test coverage detected