From 18309ec919665c02ed361780cba596c7079044cb Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Tue, 27 Feb 2024 13:14:00 +0100 Subject: [PATCH] app, prowocessing: move dev commands to tests --- crates/app/src/main.rs | 31 ++--------------------------- crates/prowocessing/src/lib.rs | 36 ++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 37 deletions(-) diff --git a/crates/app/src/main.rs b/crates/app/src/main.rs index 7780bbb..9c7c0de 100644 --- a/crates/app/src/main.rs +++ b/crates/app/src/main.rs @@ -60,38 +60,11 @@ mod dev { use clap::Subcommand; #[derive(Subcommand)] - pub(crate) enum DevCommands { - Enums { test_str: String }, - Add { num0: i32, num1: i32 }, - } + pub(crate) enum DevCommands {} impl DevCommands { pub fn run(self) { - match self { - DevCommands::Enums { test_str } => { - use prowocessing::experimental::enum_based::PipelineBuilder; - - let upr = PipelineBuilder::new() - .insert(prowocessing::experimental::enum_based::Instruction::Uppercase) - .build(); - let lwr = PipelineBuilder::new() - .insert(prowocessing::experimental::enum_based::Instruction::Lowercase) - .build(); - - println!("Upr: {}", upr.run(test_str.clone())); - println!("Lwr: {}", lwr.run(test_str.clone())); - } - DevCommands::Add { num0, num1 } => { - use prowocessing::experimental::trait_based::pipeline::PipelineBuilder; - - let pipe = PipelineBuilder::new().add(1).stringify().build(); - println!( - "{:?}", - pipe.run(vec![&num0.into(), &num1.into()].into()) - .into_inner()[0] - ); - } - } + println!("There are currently no dev commands."); } } } diff --git a/crates/prowocessing/src/lib.rs b/crates/prowocessing/src/lib.rs index aa81057..083eb4f 100644 --- a/crates/prowocessing/src/lib.rs +++ b/crates/prowocessing/src/lib.rs @@ -8,13 +8,33 @@ /// Gonna first try string processing... pub mod experimental; -#[test] -fn test_enums() { - use crate::experimental::enum_based::{Instruction, PipelineBuilder}; - let builder = PipelineBuilder::new().insert(Instruction::Uppercase); - let upr = builder.build(); - let upr_lowr = builder.insert(Instruction::Lowercase).build(); +#[cfg(test)] +mod tests { + use crate::experimental::{ + enum_based, + trait_based::{self, data::io::Outputs}, + }; - assert_eq!(upr.run(String::from("Test")), String::from("TEST")); - assert_eq!(upr_lowr.run(String::from("Test")), String::from("test")); + #[test] + fn test_enums() { + let builder = enum_based::PipelineBuilder::new().insert(enum_based::Instruction::Uppercase); + let upr = builder.build(); + let upr_lowr = builder.insert(enum_based::Instruction::Lowercase).build(); + + assert_eq!(upr.run(String::from("Test")), String::from("TEST")); + assert_eq!(upr_lowr.run(String::from("Test")), String::from("test")); + } + + #[test] + fn add() { + let pipe = trait_based::pipeline::PipelineBuilder::new() + .add(0) + .stringify() + .build(); + + assert_eq!( + pipe.run(vec![&2.into(), &3.into()].into()), + Outputs(vec![String::from("5").into()]) + ); + } }