From fe4255d765d24b3a62094a02d35077a1022887bb Mon Sep 17 00:00:00 2001 From: HampusM Date: Tue, 26 Sep 2023 19:46:15 +0200 Subject: test: make unit tests not return Result --- macros/src/factory/declare_default_args.rs | 23 +++++++++-------------- macros/src/factory/macro_args.rs | 8 ++------ macros/src/factory/type_alias.rs | 8 ++------ 3 files changed, 13 insertions(+), 26 deletions(-) (limited to 'macros/src/factory') diff --git a/macros/src/factory/declare_default_args.rs b/macros/src/factory/declare_default_args.rs index f93d29d..9930f4f 100644 --- a/macros/src/factory/declare_default_args.rs +++ b/macros/src/factory/declare_default_args.rs @@ -57,8 +57,6 @@ impl Parse for DeclareDefaultFactoryMacroArgs #[cfg(test)] mod tests { - use std::error::Error; - use proc_macro2::Span; use quote::{format_ident, quote}; use syn::token::Dyn; @@ -80,13 +78,14 @@ mod tests use crate::macro_flag::MacroFlagValue; #[test] - fn can_parse_with_interface_only() -> Result<(), Box> + fn can_parse_with_interface_only() { let input_args = quote! { dyn IFoo }; - let dec_def_fac_args = parse2::(input_args)?; + let dec_def_fac_args = + parse2::(input_args).unwrap(); assert_eq!( dec_def_fac_args.interface, @@ -108,18 +107,17 @@ mod tests ); assert!(dec_def_fac_args.flags.is_empty()); - - Ok(()) } #[test] - fn can_parse_with_interface_and_single_flag() -> Result<(), Box> + fn can_parse_with_interface_and_single_flag() { let input_args = quote! { dyn IBar, threadsafe = true }; - let dec_def_fac_args = parse2::(input_args)?; + let dec_def_fac_args = + parse2::(input_args).unwrap(); assert_eq!( dec_def_fac_args.interface, @@ -150,18 +148,17 @@ mod tests ))) }]) ); - - Ok(()) } #[test] - fn can_parse_with_interface_and_multiple_flags() -> Result<(), Box> + fn can_parse_with_interface_and_multiple_flags() { let input_args = quote! { dyn IBar, threadsafe = true, async = false }; - let dec_def_fac_args = parse2::(input_args)?; + let dec_def_fac_args = + parse2::(input_args).unwrap(); assert_eq!( dec_def_fac_args.interface, @@ -201,8 +198,6 @@ mod tests } ]) ); - - Ok(()) } #[test] diff --git a/macros/src/factory/macro_args.rs b/macros/src/factory/macro_args.rs index 76b29a2..676b412 100644 --- a/macros/src/factory/macro_args.rs +++ b/macros/src/factory/macro_args.rs @@ -46,8 +46,6 @@ impl Parse for FactoryMacroArgs #[cfg(test)] mod tests { - use std::error::Error; - use proc_macro2::Span; use quote::{format_ident, quote}; use syn::{parse2, Lit, LitBool}; @@ -56,13 +54,13 @@ mod tests use crate::macro_flag::MacroFlagValue; #[test] - fn can_parse_with_single_flag() -> Result<(), Box> + fn can_parse_with_single_flag() { let input_args = quote! { threadsafe = true }; - let factory_macro_args = parse2::(input_args)?; + let factory_macro_args = parse2::(input_args).unwrap(); assert_eq!( factory_macro_args.flags, @@ -74,8 +72,6 @@ mod tests ))) }]) ); - - Ok(()) } #[test] diff --git a/macros/src/factory/type_alias.rs b/macros/src/factory/type_alias.rs index fafcd54..cfa254f 100644 --- a/macros/src/factory/type_alias.rs +++ b/macros/src/factory/type_alias.rs @@ -31,8 +31,6 @@ impl Parse for FactoryTypeAlias #[cfg(test)] mod tests { - use std::error::Error; - use quote::{format_ident, quote}; use syn::punctuated::Punctuated; use syn::token::And; @@ -42,13 +40,13 @@ mod tests use crate::test_utils; #[test] - fn can_parse() -> Result<(), Box> + fn can_parse() { let input_args = quote! { type FooFactory = dyn Fn(String, &u32) -> Foo; }; - let factory_type_alias = parse2::(input_args)?; + let factory_type_alias = parse2::(input_args).unwrap(); assert_eq!( factory_type_alias.factory_interface.inputs, @@ -66,7 +64,5 @@ mod tests }) ]) ); - - Ok(()) } } -- cgit v1.2.3-18-g5258