()
| 826 | |
| 827 | #[test] |
| 828 | fn test_apply_replace() { |
| 829 | let mut txn = MockTxn::new(); |
| 830 | let mut context = ApplyContext::new(ApplyOptions::default()); |
| 831 | let branch_id = create_test_branch(&mut txn, 1, 0); |
| 832 | let leaf_id = LeafId::new(NodeId::new(1), 0); |
| 833 | |
| 834 | // Create first |
| 835 | let insert_op = LeafOp::Insert { |
| 836 | after: None, |
| 837 | kind: TokenKind::Word, |
| 838 | content: b"hello".to_vec(), |
| 839 | }; |
| 840 | apply_leaf_op( |
| 841 | &mut txn, |
| 842 | &mut context, |
| 843 | branch_id, |
| 844 | leaf_id, |
| 845 | &insert_op, |
| 846 | b"hello", |
| 847 | ) |
| 848 | .unwrap(); |
| 849 | |
| 850 | // Replace content |
| 851 | let replace_op = LeafOp::Replace { |
| 852 | leaf: leaf_id, |
| 853 | new_content: b"world".to_vec(), |
| 854 | }; |
| 855 | apply_leaf_op( |
| 856 | &mut txn, |
| 857 | &mut context, |
| 858 | branch_id, |
| 859 | leaf_id, |
| 860 | &replace_op, |
| 861 | b"world", |
| 862 | ) |
| 863 | .unwrap(); |
| 864 | |
| 865 | // Leaf should still exist with same ID |
| 866 | let leaf = txn.get_leaf(leaf_id).unwrap().unwrap(); |
| 867 | assert!(leaf.state().is_alive()); |
| 868 | assert_eq!(context.stats().leaves_replaced(), 1); |
| 869 | } |
| 870 | |
| 871 | #[test] |
| 872 | fn test_apply_replace_not_found() { |
nothing calls this directly
no test coverage detected