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

Function end_round_with_reset

battlecode-engine/src/research.rs:345–379  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

343
344 #[test]
345 fn end_round_with_reset() {
346 let mut r = ResearchInfo::new();
347 let knight_cost = super::cost_of(&Branch::Knight, 1).unwrap();
348 let mage_cost = super::cost_of(&Branch::Mage, 1).unwrap();
349
350 // Start researching the knight and the mage.
351 assert!(r.add_to_queue(&Branch::Knight));
352 assert!(r.add_to_queue(&Branch::Mage));
353
354 // Assume the Knight costs more than one round.
355 assert!(knight_cost > 1);
356
357 // Proceed one round.
358 assert_eq!(r.end_round(), None);
359 assert_eq!(r.rounds_left().unwrap(), knight_cost - 1);
360 assert_eq!(r.get_level(&Branch::Knight), 0);
361 assert_eq!(r.get_level(&Branch::Mage), 0);
362
363 // Reset the queue and proceed a round.
364 assert!(r.reset_queue());
365 assert_eq!(r.end_round(), None);
366 assert_err!(r.rounds_left(), GameError::NullValue);
367 assert_eq!(r.get_level(&Branch::Knight), 0);
368 assert_eq!(r.get_level(&Branch::Mage), 0);
369
370 // Start researching again and proceed to completion.
371 assert!(r.add_to_queue(&Branch::Knight));
372 assert!(r.add_to_queue(&Branch::Mage));
373 for _ in 0..knight_cost + mage_cost {
374 r.end_round();
375 }
376 assert_err!(r.rounds_left(), GameError::NullValue);
377 assert_eq!(r.get_level(&Branch::Knight), 1);
378 assert_eq!(r.get_level(&Branch::Mage), 1);
379 }
380}

Callers

nothing calls this directly

Calls 2

cost_ofFunction · 0.85
end_roundMethod · 0.45

Tested by

no test coverage detected