From b4bbe8a7733ce8f45cbd0d9b337ce3cb29f75e98 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sat, 4 Dec 2021 18:22:12 -0300 Subject: Add helpers for integer and float arguments --- tests/arguments.rs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/arguments.rs b/tests/arguments.rs index 4b5a2a0..55b4a4b 100644 --- a/tests/arguments.rs +++ b/tests/arguments.rs @@ -7,12 +7,13 @@ #![allow(non_snake_case)] use ::std::io::Cursor; -use ::std::marker::PhantomData; use ::iosonism::args::ArgumentType; use ::iosonism::args::BoolArgumentType; -use ::iosonism::args::FloatArgumentType; -use ::iosonism::args::IntegerArgumentType; +use ::iosonism::args::bounded_float; +use ::iosonism::args::bounded_integer; +use ::iosonism::args::float; +use ::iosonism::args::integer; use ::iosonism::strcursor::StringReader; mod common; @@ -45,7 +46,7 @@ fn test_i32__parse() { let mut reader = Cursor::new("15"); assert_eq!( ArgumentType::<(), ErrorPanic>::parse( - &IntegerArgumentType { range: .., _ty: PhantomData:: }, + &integer::(), &mut reader, ), Ok(15), @@ -57,7 +58,7 @@ fn test_i32__parse() { fn test_i32__parse__range() { let mut reader = Cursor::new("-5"); assert!(ArgumentType::<(), ErrorCall>::parse( - &IntegerArgumentType { range: 0..=100, _ty: PhantomData:: }, + &bounded_integer(0..100i32), &mut reader, ).is_err()); struct ErrFn; @@ -74,7 +75,7 @@ fn test_i64__parse() { let mut reader = Cursor::new("15"); assert_eq!( ArgumentType::<(), ErrorPanic>::parse( - &IntegerArgumentType { range: .., _ty: PhantomData:: }, + &integer::(), &mut reader, ), Ok(15), @@ -86,7 +87,7 @@ fn test_i64__parse() { fn test_i64__parse__range() { let mut reader = Cursor::new("-5"); assert!(ArgumentType::<(), ErrorCall>::parse( - &IntegerArgumentType { range: 0..=100, _ty: PhantomData:: }, + &bounded_integer(0..100i64), &mut reader, ).is_err()); struct ErrFn; @@ -103,7 +104,7 @@ fn test_f32__parse() { let mut reader = Cursor::new("15"); assert_eq!( ArgumentType::<(), ErrorPanic>::parse( - &FloatArgumentType { range: .., _ty: PhantomData:: }, + &float::(), &mut reader, ), Ok(15.0), @@ -115,7 +116,7 @@ fn test_f32__parse() { fn test_f32__parse__range() { let mut reader = Cursor::new("-5"); assert!(ArgumentType::<(), ErrorCall>::parse( - &FloatArgumentType { range: 0.0..=100.0, _ty: PhantomData:: }, + &bounded_float(0.0..100f32), &mut reader, ).is_err()); struct ErrFn; @@ -132,7 +133,7 @@ fn test_f64__parse() { let mut reader = Cursor::new("15"); assert_eq!( ArgumentType::<(), ErrorPanic>::parse( - &FloatArgumentType { range: .., _ty: PhantomData:: }, + &float::(), &mut reader, ), Ok(15.0), @@ -144,7 +145,7 @@ fn test_f64__parse() { fn test_f64__parse__range() { let mut reader = Cursor::new("-5"); assert!(ArgumentType::<(), ErrorCall>::parse( - &FloatArgumentType { range: 0.0..=100.0, _ty: PhantomData:: }, + &bounded_float(0.0..100f64), &mut reader, ).is_err()); struct ErrFn; -- cgit 1.4.1