func TestFillStructRecursiveWithRepeatedPtrStruct(t *testing.T) {
	config := &ConfigurationWithRepeatedStruct{}

	// init parsers
	parsers := map[reflect.Type]parse.Parser{}
	var stringParser parse.StringValue
	parsers[reflect.TypeOf("")] = &stringParser

	// init valMap
	valMap := map[string]parse.Parser{}
	stringParser.SetValue("test")
	valMap["container.repeated.val"] = &stringParser

	// init defaultValMap NoConfigAllDefault
	defaultValMap := map[string]reflect.Value{
		"repeated":  reflect.ValueOf(&RepeatedStruct{Val: "Default"}),
		"container": reflect.ValueOf(&RepeatedStructContainer{&RepeatedStruct{Val: "DefaultInContainer"}}),
	}

	// test
	if err := fillStructRecursive(reflect.ValueOf(config), defaultValMap, valMap, ""); err != nil {
		t.Fatal(err)
	}

	// CHECK
	check := &ConfigurationWithRepeatedStruct{}
	check.Container = &RepeatedStructContainer{
		&RepeatedStruct{
			Val: "test",
		},
	}
	if !reflect.DeepEqual(config, check) {
		if !reflect.DeepEqual(config.Container, check.Container) {
			t.Errorf("\nexpected\t: %+v\ngot\t\t\t: %+v", check.Container, config.Container)
		}
		t.Errorf("Error :\nexpected \t%+v \ngot \t\t%+v\n", check, config)
	}
}
// Test fillStructRecursive with repeated struct (with one on root)
Test fillStructRecursive with repeated struct (with one on root)
// Test fillStructRecursive with repeated struct ( with one on root )
func TestFillStructRecursiveWithRepeatedPtrStruct(t *testing.T) {
	config := &ConfigurationWithRepeatedStruct{}
	parsers := map[reflect.Type]parse.Parser{}
	var stringParser parse.StringValue
	parsers[reflect.TypeOf("")] = &stringParser
	valMap := map[string]parse.Parser{}
	stringParser.SetValue("test")
	valMap["container.repeated.val"] = &stringParser
	defaultValMap := map[string]reflect.Value{
		"repeated":  reflect.ValueOf(&RepeatedStruct{Val: "Default"}),
		"container": reflect.ValueOf(&RepeatedStructContainer{&RepeatedStruct{Val: "DefaultInContainer"}}),
	}
	if err := fillStructRecursive(reflect.ValueOf(config), defaultValMap, valMap, ""); err != nil {
		t.Fatal(err)
	}
	check := &ConfigurationWithRepeatedStruct{}
	check.Container = &RepeatedStructContainer{
		&RepeatedStruct{
			Val: "test",
		},
	}
	if !reflect.DeepEqual(config, check) {
		if !reflect.DeepEqual(config.Container, check.Container) {
			t.Errorf("\nexpected\t: %+v\ngot\t\t\t: %+v", check.Container, config.Container)
		}
		t.Errorf("Error :\nexpected \t%+v \ngot \t\t%+v\n", check, config)
	}
}
func TestFillStructRecursiveWithRepeatedPtrStruct ( t * testing . T ) { config := & ConfigurationWithRepeatedStruct { } parsers := map [ reflect . Type ] parse . Parser { } var stringParser parse . StringValue parsers [ reflect . TypeOf ( " " ) ] = & stringParser valMap := map [ string ] parse . Parser { } stringParser . SetValue ( " " ) valMap [ " " ] = & stringParser defaultValMap := map [ string ] reflect . Value { " " : reflect . ValueOf ( & RepeatedStruct { Val : " " } ) , " " : reflect . ValueOf ( & RepeatedStructContainer { & RepeatedStruct { Val : " " } } ) , } if err := fillStructRecursive ( reflect . ValueOf ( config ) , defaultValMap , valMap , " " ) ; err != nil { t . Fatal ( err ) } check := & ConfigurationWithRepeatedStruct { } check . Container = & RepeatedStructContainer { & RepeatedStruct { Val : " " , } , } if ! reflect . DeepEqual ( config , check ) { if ! reflect . DeepEqual ( config . Container , check . Container ) { t . Errorf ( " \n \t \n \t \t \t " , check . Container , config . Container ) } t . Errorf ( " \n \t \n \t \t \n " , check , config ) } }
Test fillStructRecursive with repeated struct (with one on root)
Test fillStructRecursive with repeated struct ( with one on root )
// init parsers // init valMap // init defaultValMap NoConfigAllDefault // test // CHECK