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

Function test_binary_content

atomic-core/src/change/store.rs:1091–1117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1089
1090 #[test]
1091 fn test_binary_content() {
1092 let store = MemoryChangeStore::new();
1093 let content: Vec<u8> = (0..=255).collect();
1094 let change = create_test_change("Binary", &content);
1095 let hash = change.hash().unwrap();
1096 store.insert(hash, change);
1097
1098 let node_id = NodeId::new(1);
1099 let hash_fn = move |id: NodeId| {
1100 if id == node_id {
1101 Some(hash)
1102 } else {
1103 None
1104 }
1105 };
1106
1107 let node = GraphNode::new(
1108 node_id,
1109 ChangePosition::new(0),
1110 ChangePosition::new(content.len() as u64),
1111 );
1112 let mut buf = vec![0u8; content.len()];
1113
1114 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1115 assert_eq!(n, content.len());
1116 assert_eq!(buf, content);
1117 }
1118
1119 #[test]
1120 fn test_multiple_changes() {

Callers

nothing calls this directly

Calls 7

create_test_changeFunction · 0.70
collectMethod · 0.45
unwrapMethod · 0.45
hashMethod · 0.45
insertMethod · 0.45
lenMethod · 0.45
get_contentsMethod · 0.45

Tested by

no test coverage detected