func TestGetDefaultValueInitConfigNoDefault(t *testing.T) {
	config := &Configuration{
		Name: "defaultName", // useless field not flaged
		// LogLevel is not initialized, default value will be go default value : ""
		Timeout: parse.Duration(time.Millisecond),
	}
	defPointerConfig := &Configuration{
		Db: nil, //If pointer field is nil, default value will be go default value
		// Owner is not initialized, default value will be go default value
	}
	defaultValMap := make(map[string]reflect.Value)

	if err := getDefaultValue(reflect.ValueOf(config), reflect.ValueOf(defPointerConfig), defaultValMap, ""); err != nil {
		t.Fatal(err)
	}

	checkValue := map[string]reflect.Value{
		"loglevel":           reflect.ValueOf(""),
		"timeout":            reflect.ValueOf(parse.Duration(time.Millisecond)),
		"db":                 reflect.ValueOf(&DatabaseInfo{}),
		"db.watch":           reflect.ValueOf(false),
		"db.ip":              reflect.ValueOf(""),
		"db.load":            reflect.ValueOf(0),
		"db.load64":          reflect.ValueOf(int64(0)),
		"db.comax":           reflect.ValueOf(uint(0)),
		"db.connectionmax64": reflect.ValueOf(uint64(0)),
		"owner":              reflect.ValueOf(&OwnerInfo{}),
		"owner.name":         reflect.ValueOf(new(string)),
		"owner.dob":          reflect.ValueOf(time.Time{}),
		"owner.rate":         reflect.ValueOf(float64(0)),
		"owner.servers":      reflect.ValueOf(*new([]ServerInfo)),
	}

	if len(checkValue) != len(defaultValMap) {
		t.Errorf("expected %d elements in defaultValMap got %d", len(checkValue), len(defaultValMap))
	}

	for flag, val := range defaultValMap {
		if !reflect.DeepEqual(checkValue[flag].Interface(), val.Interface()) {
			t.Errorf("flag %s : \nexpected \t%+v \ngot \t\t%+v\n", flag, checkValue[flag], val)
		}
	}
}
// Test getDefaultValue on a full complex struct, with anonymous field, nil pointers and not initialized fields
Test getDefaultValue on a full complex struct, with anonymous field, nil pointers and not initialized fields
// Test getDefaultValue on a full complex struct with anonymous field nil pointers and not initialized fields
func TestGetDefaultValueInitConfigNoDefault(t *testing.T) {
	config := &Configuration{
		Name: "defaultName", 
		Timeout: parse.Duration(time.Millisecond),
	}
	defPointerConfig := &Configuration{
		Db: nil, 
	}
	defaultValMap := make(map[string]reflect.Value)
	if err := getDefaultValue(reflect.ValueOf(config), reflect.ValueOf(defPointerConfig), defaultValMap, ""); err != nil {
		t.Fatal(err)
	}
	checkValue := map[string]reflect.Value{
		"loglevel":           reflect.ValueOf(""),
		"timeout":            reflect.ValueOf(parse.Duration(time.Millisecond)),
		"db":                 reflect.ValueOf(&DatabaseInfo{}),
		"db.watch":           reflect.ValueOf(false),
		"db.ip":              reflect.ValueOf(""),
		"db.load":            reflect.ValueOf(0),
		"db.load64":          reflect.ValueOf(int64(0)),
		"db.comax":           reflect.ValueOf(uint(0)),
		"db.connectionmax64": reflect.ValueOf(uint64(0)),
		"owner":              reflect.ValueOf(&OwnerInfo{}),
		"owner.name":         reflect.ValueOf(new(string)),
		"owner.dob":          reflect.ValueOf(time.Time{}),
		"owner.rate":         reflect.ValueOf(float64(0)),
		"owner.servers":      reflect.ValueOf(*new([]ServerInfo)),
	}
	if len(checkValue) != len(defaultValMap) {
		t.Errorf("expected %d elements in defaultValMap got %d", len(checkValue), len(defaultValMap))
	}
	for flag, val := range defaultValMap {
		if !reflect.DeepEqual(checkValue[flag].Interface(), val.Interface()) {
			t.Errorf("flag %s : \nexpected \t%+v \ngot \t\t%+v\n", flag, checkValue[flag], val)
		}
	}
}
func TestGetDefaultValueInitConfigNoDefault ( t * testing . T ) { config := & Configuration { Name : " " , Timeout : parse . Duration ( time . Millisecond ) , } defPointerConfig := & Configuration { Db : nil , } defaultValMap := make ( map [ string ] reflect . Value ) if err := getDefaultValue ( reflect . ValueOf ( config ) , reflect . ValueOf ( defPointerConfig ) , defaultValMap , " " ) ; err != nil { t . Fatal ( err ) } checkValue := map [ string ] reflect . Value { " " : reflect . ValueOf ( " " ) , " " : reflect . ValueOf ( parse . Duration ( time . Millisecond ) ) , " " : reflect . ValueOf ( & DatabaseInfo { } ) , " " : reflect . ValueOf ( false ) , " " : reflect . ValueOf ( " " ) , " " : reflect . ValueOf ( 0 ) , " " : reflect . ValueOf ( int64 ( 0 ) ) , " " : reflect . ValueOf ( uint ( 0 ) ) , " " : reflect . ValueOf ( uint64 ( 0 ) ) , " " : reflect . ValueOf ( & OwnerInfo { } ) , " " : reflect . ValueOf ( new ( string ) ) , " " : reflect . ValueOf ( time . Time { } ) , " " : reflect . ValueOf ( float64 ( 0 ) ) , " " : reflect . ValueOf ( * new ( [ ] ServerInfo ) ) , } if len ( checkValue ) != len ( defaultValMap ) { t . Errorf ( " " , len ( checkValue ) , len ( defaultValMap ) ) } for flag , val := range defaultValMap { if ! reflect . DeepEqual ( checkValue [ flag ] . Interface ( ) , val . Interface ( ) ) { t . Errorf ( " \n \t \n \t \t \n " , flag , checkValue [ flag ] , val ) } } }
Test getDefaultValue on a full complex struct, with anonymous field, nil pointers and not initialized fields
Test getDefaultValue on a full complex struct with anonymous field nil pointers and not initialized fields
// useless field not flaged // LogLevel is not initialized, default value will be go default value : "" //If pointer field is nil, default value will be go default value // Owner is not initialized, default value will be go default value