MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / test_sequence_complex_ordering

Function test_sequence_complex_ordering

atomic-core/src/crdt/apply/order.rs:756–779  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

754
755 #[test]
756 fn test_sequence_complex_ordering() {
757 let mut seq: OrderingSequence<BranchId> = OrderingSequence::new();
758
759 // Simulate a more complex scenario:
760 // - Line 1 is added at start
761 // - Lines 2 and 4 are concurrently added after line 1
762 // - Line 3 is added after line 2
763
764 let l1 = BranchId::new(NodeId::new(1), 0);
765 let l2 = BranchId::new(NodeId::new(2), 0);
766 let l3 = BranchId::new(NodeId::new(3), 0);
767 let l4 = BranchId::new(NodeId::new(4), 0);
768
769 seq.insert(l1, None);
770 seq.insert(l4, Some(l1)); // First concurrent insert
771 seq.insert(l2, Some(l1)); // Second concurrent insert (goes before l4)
772 seq.insert(l3, Some(l2)); // After l2
773
774 // Expected order: l1, l2, l3, l4
775 assert_eq!(seq.get(0), Some(&l1));
776 assert_eq!(seq.get(1), Some(&l2));
777 assert_eq!(seq.get(2), Some(&l3));
778 assert_eq!(seq.get(3), Some(&l4));
779 }
780}

Callers

nothing calls this directly

Calls 1

insertMethod · 0.45

Tested by

no test coverage detected