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

Function roundtrip

nodedb/src/control/server/resp/codec.rs:452–469  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

450
451 #[test]
452 fn roundtrip() {
453 let values = vec![
454 RespValue::ok(),
455 RespValue::err("ERR test"),
456 RespValue::integer(99),
457 RespValue::bulk_str("hello"),
458 RespValue::nil(),
459 RespValue::array(vec![RespValue::bulk_str("a"), RespValue::integer(1)]),
460 ];
461
462 for original in &values {
463 let bytes = original.to_bytes();
464 let mut parser = RespParser::new();
465 parser.feed(&bytes);
466 let parsed = parser.try_parse().unwrap().unwrap();
467 assert_eq!(&parsed, original, "roundtrip failed for {original:?}");
468 }
469 }
470}

Callers

nothing calls this directly

Calls 3

try_parseMethod · 0.80
to_bytesMethod · 0.45
feedMethod · 0.45

Tested by

no test coverage detected