| 954 | |
| 955 | #[test] |
| 956 | fn test_atom_postcard_roundtrip() { |
| 957 | let atoms: Vec<Atom<Hash>> = vec![ |
| 958 | Atom::Insertion(Insertion { |
| 959 | predecessors: vec![test_hash_position(0)], |
| 960 | successors: vec![], |
| 961 | flag: EdgeFlags::BLOCK, |
| 962 | start: ChangePosition::new(0), |
| 963 | end: ChangePosition::new(100), |
| 964 | inode: test_hash_position(42), |
| 965 | }), |
| 966 | Atom::EdgeUpdate(EdgeUpdate { |
| 967 | edges: vec![NewEdge { |
| 968 | previous: EdgeFlags::BLOCK, |
| 969 | flag: EdgeFlags::DELETED, |
| 970 | from: test_hash_position(0), |
| 971 | to: GraphNode::new( |
| 972 | Hash::of(b"x"), |
| 973 | ChangePosition::new(0), |
| 974 | ChangePosition::new(5), |
| 975 | ), |
| 976 | introduced_by: Hash::of(b"intro"), |
| 977 | }], |
| 978 | inode: test_hash_position(42), |
| 979 | }), |
| 980 | ]; |
| 981 | |
| 982 | for atom in atoms { |
| 983 | let bytes = postcard::to_allocvec(&atom).unwrap(); |
| 984 | let parsed: Atom<Hash> = postcard::from_bytes(&bytes).unwrap(); |
| 985 | assert_eq!(atom, parsed); |
| 986 | } |
| 987 | } |
| 988 | |
| 989 | // Edge Cases |
| 990 | |