type Ctx = UsualCtx;
impl Ctx {
+ #[throws(Explode)]
+ fn check_library_item(&mut self, itemlib: &str, item: &str,
+ desc: &str) {
+ let ds = self.su().ds.also(&[
+ ("itemlib", itemlib),
+ ("item", item ),
+ ]);
+ let command = ds.ss("library-add --lib @itemlib@ @table@ @item@")?;
+ let added = self.some_library_add(&command)?;
+ assert_eq!( added.len(), 1 );
+
+ let output: String = self.otter(&ds.ss("list-pieces @table@")?)?.into();
+ assert!( Regex::new(
+ &format!(
+ r#"(?m)(?:[^\w-]|^){}[^\w-].*\W{}(?:\W|$)"#,
+ item, desc,
+ )
+ )?
+ .find(&output)
+ .is_some(),
+ "got: {}", &output);
+ }
+
#[throws(Explode)]
fn bundles(&mut self) {
let bundle_file = self.su().ds.example_bundle();
let st = Command::new("cmp").args(&[&bundle_file, "00000.zip"]).status()?;
if ! st.success() { panic!("cmp failed {}", st) }
- let command = ds.ss("library-add --lib lemon @table@ example-lemon")?;
- let added = self.some_library_add(&command)?;
- assert_eq!( added.len(), 1 );
-
- let output: String = self.otter(&ds.ss("list-pieces @table@")?)?.into();
- assert!( Regex::new(
- r#"(?m)(?:[^\w-]|^)example-lemon[^\w-].*\Wa lemon(?:\W|$)"#
- )?
- .find(&output)
- .is_some(),
- "got: {}", &output);
+ self.check_library_item("lemon","example-lemon","a lemon")?;
self.otter(&ds.ss("clear-game @table@")?)?;
self.otter(&ds.ss("reset @table@ demo")?)?;