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

Function test_single_byte_content

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

Source from the content-addressed store, hash-verified

1011
1012 #[test]
1013 fn test_single_byte_content() {
1014 let store = MemoryChangeStore::new();
1015 let content = b"X";
1016 let change = create_test_change("Single byte", content);
1017 let hash = change.hash().unwrap();
1018 store.insert(hash, change);
1019
1020 let node_id = NodeId::new(1);
1021 let hash_fn = move |id: NodeId| {
1022 if id == node_id {
1023 Some(hash)
1024 } else {
1025 None
1026 }
1027 };
1028
1029 let node = GraphNode::new(node_id, ChangePosition::new(0), ChangePosition::new(1));
1030 let mut buf = vec![0u8; 1];
1031
1032 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1033 assert_eq!(n, 1);
1034 assert_eq!(buf[0], b'X');
1035 }
1036
1037 #[test]
1038 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