diff --git a/module/core/former/tests/inc/former_tests/container_former_common.rs b/module/core/former/tests/inc/former_tests/container_former_common.rs index a251cef936..954e887892 100644 --- a/module/core/former/tests/inc/former_tests/container_former_common.rs +++ b/module/core/former/tests/inc/former_tests/container_former_common.rs @@ -29,15 +29,11 @@ fn definitions() { } - // f1( former::VectorDefinition::< String, () >::default() ); + f1( former::VectorDefinition::< String, (), Vec< String >, the_module::NoEnd >::default() ); f2( former::VectorDefinition::< String, (), Vec< String >, the_module::NoEnd >::default() ); f3::< former::VectorDefinition< String, (), Vec< String >, the_module::NoEnd >, the_module::ReturnStorage >( the_module::ReturnStorage ); f3::< < former::VectorDefinition< String, (), Vec< String >, the_module::NoEnd > as the_module::FormerDefinition >::Types, the_module::ReturnStorage >( the_module::ReturnStorage ); - // assert_eq!( 0, 1 ); - - let vec : Vec< String > = vec![ "a".into(), "b".into(), "c".into() ]; - } // diff --git a/module/core/former/tests/inc/former_tests/container_former_hashmap.rs b/module/core/former/tests/inc/former_tests/container_former_hashmap.rs index cfe3574aed..da24fc1ec1 100644 --- a/module/core/former/tests/inc/former_tests/container_former_hashmap.rs +++ b/module/core/former/tests/inc/former_tests/container_former_hashmap.rs @@ -8,14 +8,71 @@ use collection_tools::HashMap; // qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] #[ cfg( not( feature = "use_alloc" ) ) ] #[ test ] -fn push() +fn add() { - // + // expliccit with ContainerSubformer + + let got : HashMap< String, String > = the_module + ::ContainerSubformer + ::< ( String, String ), former::HashMapDefinition< String, String, (), HashMap< String, String >, the_module::ReturnStorage > > + ::new( former::ReturnStorage ) + .add( ( "a".into(), "x".into() ) ) + .add( ( "b".into(), "y".into() ) ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + + // expliccit with HashMapSubformer + + let got : HashMap< String, String > = the_module::HashMapSubformer::< String, String, (), HashMap< String, String >, the_module::ReturnStorage > + ::new( former::ReturnStorage ) + .add( ( "a".into(), "x".into() ) ) + .add( ( "b".into(), "y".into() ) ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + + // compact with HashMapSubformer + + let got : HashMap< String, String > = the_module::HashMapSubformer::new( former::ReturnStorage ) + .add( ( "a".into(), "x".into() ) ) + .add( ( "b".into(), "y".into() ) ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + + // with begin + + let got : HashMap< String, String > = the_module::HashMapSubformer + ::begin( Some( hmap![ "a".to_string() => "x".to_string() ] ), Some( () ), former::ReturnStorage ) + .add( ( "b".into(), "y".into() ) ) + .form(); + let exp = hmap! + [ + "a".to_string() => "x".to_string(), + "b".to_string() => "y".to_string(), + ]; + a_id!( got, exp ); + + // with help of ext - let got : HashMap< String, String > = the_module::HashMapSubformer::new() - .insert( "a", "x" ) - .insert( "b", "y" ) + use the_module::HashMapExt; + let got : HashMap< String, String > = HashMap::former() + .add( ( "a".into(), "x".into() ) ) + .add( ( "b".into(), "y".into() ) ) .form(); let exp = hmap! [ @@ -24,6 +81,8 @@ fn push() ]; a_id!( got, exp ); + // + } // qqq : zzz : remove #[ cfg( not( feature = "use_alloc" ) ) ] @@ -32,9 +91,9 @@ fn push() fn replace() { - let got : HashMap< String, String > = the_module::HashMapSubformer::new() - .insert( "x", "x" ) - .replace( hmap![ "a".to_string() => "x".to_string(), "b".to_string() => "y".to_string() ] ) + let got : HashMap< String, String > = the_module::HashMapSubformer::new( former::ReturnStorage ) + .add( ( "x".to_string(), "y".to_string() ) ) + .replace( hmap![ "a".to_string() => "x".to_string(), "b".to_string() => "y".to_string(), ] ) .form(); let exp = hmap! [ @@ -44,4 +103,3 @@ fn replace() a_id!( got, exp ); } - diff --git a/module/core/former/tests/inc/mod.rs b/module/core/former/tests/inc/mod.rs index e8b2ed3c47..6e963751ab 100644 --- a/module/core/former/tests/inc/mod.rs +++ b/module/core/former/tests/inc/mod.rs @@ -13,8 +13,8 @@ mod former_tests mod container_former_vec; #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] mod container_former_hashset; - // #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] - // mod container_former_hashmap; + #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ] + mod container_former_hashmap; // mod a_primitives_manual; // mod a_primitives;