MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / read_str_advance_basic

Function read_str_advance_basic

nodedb-query/src/msgpack_scan/reader.rs:1110–1129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1108
1109 #[test]
1110 fn read_str_advance_basic() {
1111 // fixstr "hi"
1112 let mut off = 0;
1113 let buf = encode(&json!("hi"));
1114 assert_eq!(read_str_advance(&buf, &mut off), Some("hi"));
1115 assert_eq!(off, buf.len());
1116
1117 // Sequential reads
1118 let buf = encode(&json!(["one", "two"]));
1119 let (count, mut off) = array_header(&buf, 0).unwrap();
1120 assert_eq!(count, 2);
1121 assert_eq!(read_str_advance(&buf, &mut off), Some("one"));
1122 assert_eq!(read_str_advance(&buf, &mut off), Some("two"));
1123 assert_eq!(off, buf.len());
1124
1125 // Non-string returns None.
1126 let mut off = 0;
1127 assert_eq!(read_str_advance(&[NIL], &mut off), None);
1128 assert_eq!(off, 0);
1129 }
1130
1131 /// Empty buffer must return `None` for all functions that can.
1132 #[test]

Callers

nothing calls this directly

Calls 2

array_headerFunction · 0.85
encodeFunction · 0.70

Tested by

no test coverage detected