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

Function test_stats_from_file_ops

atomic-core/src/change/ops.rs:1667–1696  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1665
1666 #[test]
1667 fn test_stats_from_file_ops() {
1668 let mut file1 =
1669 FileOps::create(test_trunk_id(), "new.txt".to_string(), Some(Encoding::Utf8));
1670 file1.add_line_op(LineOps::insert(
1671 test_branch_id(0),
1672 None,
1673 vec![
1674 LeafOp::Insert {
1675 after: None,
1676 kind: TokenKind::Word,
1677 content: b"Hello".to_vec(),
1678 },
1679 LeafOp::Insert {
1680 after: None,
1681 kind: TokenKind::Word,
1682 content: b"World".to_vec(),
1683 },
1684 ],
1685 ));
1686
1687 let file2 = FileOps::delete(TrunkId::new(NodeId::new(2), 0), "old.txt".to_string());
1688
1689 let stats = FileOpsStats::from_file_ops(&[file1, file2]);
1690
1691 assert_eq!(stats.files_created, 1);
1692 assert_eq!(stats.files_deleted, 1);
1693 assert_eq!(stats.lines_added, 1);
1694 assert_eq!(stats.tokens_added, 2);
1695 assert!(stats.has_changes());
1696 }
1697
1698 #[test]
1699 fn test_stats_display() {

Callers

nothing calls this directly

Calls 5

test_branch_idFunction · 0.85
test_trunk_idFunction · 0.70
createFunction · 0.50
insertFunction · 0.50
add_line_opMethod · 0.45

Tested by

no test coverage detected