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

Function test_binary_content

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

Source from the content-addressed store, hash-verified

1065
1066 #[test]
1067 fn test_binary_content() {
1068 let store = MemoryChangeStore::new();
1069 let content: Vec<u8> = (0..=255).collect();
1070 let change = create_test_change("Binary", &content);
1071 let hash = change.hash().unwrap();
1072 store.insert(hash, change);
1073
1074 let node_id = NodeId::new(1);
1075 let hash_fn = move |id: NodeId| {
1076 if id == node_id {
1077 Some(hash)
1078 } else {
1079 None
1080 }
1081 };
1082
1083 let node = GraphNode::new(
1084 node_id,
1085 ChangePosition::new(0),
1086 ChangePosition::new(content.len() as u64),
1087 );
1088 let mut buf = vec![0u8; content.len()];
1089
1090 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1091 assert_eq!(n, content.len());
1092 assert_eq!(buf, content);
1093 }
1094
1095 #[test]
1096 fn test_multiple_changes() {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected