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

Function test_file_ops_token_count

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

Source from the content-addressed store, hash-verified

1424
1425 #[test]
1426 fn test_file_ops_token_count() {
1427 let mut ops = FileOps::edit(test_trunk_id(), "test.txt".to_string());
1428
1429 // Add a line with 3 tokens
1430 ops.add_line_op(LineOps::insert(
1431 test_branch_id(0),
1432 None,
1433 vec![
1434 LeafOp::Insert {
1435 after: None,
1436 kind: TokenKind::Word,
1437 content: b"Hello".to_vec(),
1438 },
1439 LeafOp::Insert {
1440 after: None,
1441 kind: TokenKind::Whitespace,
1442 content: b" ".to_vec(),
1443 },
1444 LeafOp::Insert {
1445 after: None,
1446 kind: TokenKind::Word,
1447 content: b"World".to_vec(),
1448 },
1449 ],
1450 ));
1451
1452 // Add another line with 2 tokens
1453 ops.add_line_op(LineOps::insert(
1454 test_branch_id(1),
1455 Some(test_branch_id(0)),
1456 vec![
1457 LeafOp::Insert {
1458 after: None,
1459 kind: TokenKind::Word,
1460 content: b"Hello".to_vec(),
1461 },
1462 LeafOp::Insert {
1463 after: None,
1464 kind: TokenKind::Newline,
1465 content: b"\n".to_vec(),
1466 },
1467 ],
1468 ));
1469
1470 assert_eq!(ops.line_count(), 2);
1471 assert_eq!(ops.token_count(), 5);
1472 }
1473
1474 #[test]
1475 fn test_file_ops_display() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected