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

Function test_multiple_hunks

atomic-core/src/change/change.rs:1917–1943  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1915
1916 #[test]
1917 fn test_multiple_hunks() {
1918 let mut change = Change::empty(ChangeHeader::new("Multiple hunks"));
1919
1920 for i in 0..10 {
1921 let graph_op: GraphOp<Option<Hash>> = GraphOp::Edit {
1922 change: Atom::Insertion(Insertion {
1923 predecessors: vec![],
1924 successors: vec![],
1925 flag: EdgeFlags::BLOCK,
1926 start: ChangePosition::new(i * 10),
1927 end: ChangePosition::new((i + 1) * 10),
1928 inode: test_hash_position(0),
1929 }),
1930 local: Local::new("test.rs", i + 1),
1931 encoding: Some(Encoding::Utf8),
1932 };
1933 change.add_hunk(graph_op);
1934 }
1935
1936 let mut buffer = Vec::new();
1937 change.serialize(&mut buffer).unwrap();
1938
1939 let mut cursor = Cursor::new(buffer);
1940 let (loaded, _) = Change::deserialize(&mut cursor).unwrap();
1941
1942 assert_eq!(loaded.hunks().len(), 10);
1943 }
1944
1945 #[test]
1946 fn test_hash_stability() {

Callers

nothing calls this directly

Calls 6

InsertionClass · 0.85
test_hash_positionFunction · 0.70
deserializeFunction · 0.50
add_hunkMethod · 0.45
unwrapMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected