MCPcopy Create free account
hub / github.com/Logicalshift/flo_draw / check_round_trip

Function check_round_trip

canvas/src/decoding.rs:1744–1763  ·  view source on GitHub ↗

Checks if a particular string of drawing operations can be both encoded and decoded

(instructions: Vec<Draw>)

Source from the content-addressed store, hash-verified

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() {

Callers 2

check_round_trip_singleFunction · 0.85
decode_all_iterFunction · 0.85

Calls 2

decode_drawingFunction · 0.85
encode_canvasMethod · 0.80

Tested by 1

decode_all_iterFunction · 0.68