| 830 | |
| 831 | #[test] |
| 832 | fn test_position_cache() { |
| 833 | let mut cache: HashMap<Position<NodeId>, VertexId> = HashMap::new(); |
| 834 | |
| 835 | let pos1 = Position::new(NodeId::new(1), ChangePosition::new(0)); |
| 836 | let pos2 = Position::new(NodeId::new(1), ChangePosition::new(100)); |
| 837 | let pos3 = Position::new(NodeId::new(2), ChangePosition::new(0)); |
| 838 | |
| 839 | cache.insert(pos1, VertexId::new(1)); |
| 840 | cache.insert(pos2, VertexId::new(2)); |
| 841 | cache.insert(pos3, VertexId::new(3)); |
| 842 | |
| 843 | assert_eq!(cache.get(&pos1), Some(&VertexId::new(1))); |
| 844 | assert_eq!(cache.get(&pos2), Some(&VertexId::new(2))); |
| 845 | assert_eq!(cache.get(&pos3), Some(&VertexId::new(3))); |
| 846 | |
| 847 | // Duplicate insertion returns same ID |
| 848 | assert!(cache.contains_key(&pos1)); |
| 849 | } |
| 850 | |
| 851 | #[test] |
| 852 | fn test_position_cache_bottom() { |