From: Ian Jackson Date: Mon, 3 May 2021 23:41:58 +0000 (+0100) Subject: bundles: Test Id parsing and printing X-Git-Tag: otter-0.6.0~411 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a28598b550e4ce0adda6e02be9e1fb721b6900e1;p=otter.git bundles: Test Id parsing and printing Signed-off-by: Ian Jackson --- diff --git a/src/bundles.rs b/src/bundles.rs index 2abd5eda..2bf9aa99 100644 --- a/src/bundles.rs +++ b/src/bundles.rs @@ -369,3 +369,20 @@ impl InstanceBundles { }; } } + +#[test] +fn id_file_parse() { + let check_y = |s,index,kind| { + let id = Id { index, kind }; + assert_eq!(Id::from_str(s).unwrap(), id); + assert_eq!(id.to_string(), s); + }; + let check_n = |s,m| { + assert_eq!(Id::from_str(s).unwrap_err().to_string(), m) + }; + check_y("00000.zip", Index(0), Kind::Zip); + check_n("00000zip", "no dot"); + check_n("xxxxx.zip", "bad index"); + check_n("00000.xyz", "bad extension"); + check_n("65536.zip", "bad index"); +}