From a28598b550e4ce0adda6e02be9e1fb721b6900e1 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 4 May 2021 00:41:58 +0100 Subject: [PATCH] bundles: Test Id parsing and printing Signed-off-by: Ian Jackson --- src/bundles.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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"); +} -- 2.30.2