Checks if a particular string of drawing operations can be both encoded and decoded
(instructions: Vec<Draw>)
| 1742 | /// Checks if a particular string of drawing operations can be both encoded and decoded |
| 1743 | /// |
| 1744 | fn check_round_trip(instructions: Vec<Draw>) { |
| 1745 | // Encode the instruction |
| 1746 | let mut encoded = String::new(); |
| 1747 | for instruction in instructions.iter() { |
| 1748 | instruction.encode_canvas(&mut encoded); |
| 1749 | } |
| 1750 | |
| 1751 | println!("{:?} {:?}", instructions, encoded); |
| 1752 | |
| 1753 | // Try decoding it |
| 1754 | let decoded = decode_drawing(encoded.chars()).collect::<Vec<_>>(); |
| 1755 | |
| 1756 | println!(" -> {:?}", decoded); |
| 1757 | |
| 1758 | // Should decode OK |
| 1759 | assert!(decoded.len() == instructions.len()); |
| 1760 | |
| 1761 | // Should be the same as the original instruction |
| 1762 | assert!(decoded == instructions.into_iter().map(|draw| Ok(draw)).collect::<Vec<_>>()); |
| 1763 | } |
| 1764 | |
| 1765 | #[test] |
| 1766 | fn decode_start_frame() { |