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:870–916  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

868
869 #[test]
870 fn test_file_ops_token_count() {
871 let mut ops = FileOps::edit(test_trunk_id(), "test.txt".to_string());
872
873 // Add a line with 3 tokens
874 ops.add_line_op(LineOps::insert(
875 test_branch_id(0),
876 None,
877 vec![
878 LeafOp::Insert {
879 after: None,
880 kind: TokenKind::Word,
881 content: b"Hello".to_vec(),
882 },
883 LeafOp::Insert {
884 after: None,
885 kind: TokenKind::Whitespace,
886 content: b" ".to_vec(),
887 },
888 LeafOp::Insert {
889 after: None,
890 kind: TokenKind::Word,
891 content: b"World".to_vec(),
892 },
893 ],
894 ));
895
896 // Add another line with 2 tokens
897 ops.add_line_op(LineOps::insert(
898 test_branch_id(1),
899 Some(test_branch_id(0)),
900 vec![
901 LeafOp::Insert {
902 after: None,
903 kind: TokenKind::Word,
904 content: b"Hello".to_vec(),
905 },
906 LeafOp::Insert {
907 after: None,
908 kind: TokenKind::Newline,
909 content: b"\n".to_vec(),
910 },
911 ],
912 ));
913
914 assert_eq!(ops.line_count(), 2);
915 assert_eq!(ops.token_count(), 5);
916 }
917
918 #[test]
919 fn test_file_ops_display() {

Callers

nothing calls this directly

Calls 3

test_branch_idFunction · 0.85
test_trunk_idFunction · 0.70
add_line_opMethod · 0.45

Tested by

no test coverage detected