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

Function test_single_byte_content

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

Source from the content-addressed store, hash-verified

1035
1036 #[test]
1037 fn test_single_byte_content() {
1038 let store = MemoryChangeStore::new();
1039 let content = b"X";
1040 let change = create_test_change("Single byte", content);
1041 let hash = change.hash().unwrap();
1042 store.insert(hash, change);
1043
1044 let node_id = NodeId::new(1);
1045 let hash_fn = move |id: NodeId| {
1046 if id == node_id {
1047 Some(hash)
1048 } else {
1049 None
1050 }
1051 };
1052
1053 let node = GraphNode::new(node_id, ChangePosition::new(0), ChangePosition::new(1));
1054 let mut buf = vec![0u8; 1];
1055
1056 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1057 assert_eq!(n, 1);
1058 assert_eq!(buf[0], b'X');
1059 }
1060
1061 #[test]
1062 fn test_unicode_content() {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected