Skip to content

Commit 271258d

Browse files
add to_string() test
1 parent bbcfccc commit 271258d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/cid.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,20 @@ mod tests {
404404
assert!(cid1 != cid2);
405405
assert!(!cid2.is_null());
406406
}
407+
408+
#[test]
409+
fn test_string_roundtrip() {
410+
let v1 = Builder::new(Codec::Cidv1)
411+
.with_target_codec(Codec::DagCbor)
412+
.with_hash(
413+
&mh::Builder::new_from_bytes(Codec::Sha3512, b"for great justice, move every zig!")
414+
.unwrap()
415+
.try_build()
416+
.unwrap(),
417+
)
418+
.try_build()
419+
.unwrap();
420+
let s = v1.to_string();
421+
assert_eq!(s, EncodedCid::try_from(s.as_str()).unwrap().to_string());
422+
}
407423
}

0 commit comments

Comments
 (0)