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

Function test_unicode_content

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

Source from the content-addressed store, hash-verified

1060
1061 #[test]
1062 fn test_unicode_content() {
1063 let store = MemoryChangeStore::new();
1064 let content = "Hello, 世界! 🌍".as_bytes();
1065 let change = create_test_change("Unicode", content);
1066 let hash = change.hash().unwrap();
1067 store.insert(hash, change);
1068
1069 let node_id = NodeId::new(1);
1070 let hash_fn = move |id: NodeId| {
1071 if id == node_id {
1072 Some(hash)
1073 } else {
1074 None
1075 }
1076 };
1077
1078 let node = GraphNode::new(
1079 node_id,
1080 ChangePosition::new(0),
1081 ChangePosition::new(content.len() as u64),
1082 );
1083 let mut buf = vec![0u8; content.len()];
1084
1085 let n = store.get_contents(hash_fn, node, &mut buf).unwrap();
1086 assert_eq!(n, content.len());
1087 assert_eq!(std::str::from_utf8(&buf).unwrap(), "Hello, 世界! 🌍");
1088 }
1089
1090 #[test]
1091 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