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

Function test_unicode_content

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

Source from the content-addressed store, hash-verified

1036
1037 #[test]
1038 fn test_unicode_content() {
1039 let store = MemoryChangeStore::new();
1040 let content = "Hello, 世界! 🌍".as_bytes();
1041 let change = create_test_change("Unicode", content);
1042 let hash = change.hash().unwrap();
1043 store.insert(hash, change);
1044
1045 let node_id = NodeId::new(1);
1046 let hash_fn = move |id: NodeId| {
1047 if id == node_id {
1048 Some(hash)
1049 } else {
1050 None
1051 }
1052 };
1053
1054 let node = GraphNode::new(
1055 node_id,
1056 ChangePosition::new(0),
1057 ChangePosition::new(content.len() as u64),
1058 );
1059 let mut buf = vec![0u8; content.len()];
1060
1061 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1062 assert_eq!(n, content.len());
1063 assert_eq!(std::str::from_utf8(&buf).unwrap(), "Hello, 世界! 🌍");
1064 }
1065
1066 #[test]
1067 fn test_binary_content() {

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected