func TestGetDefaultNoConfigAllDefault(t *testing.T) {
	config := &Configuration{}
	defPointerConfig := newDefaultPointersConfiguration()
	defaultValMap := make(map[string]reflect.Value)

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

	checkStr := "DefaultOwnerNamePointer"
	checkDob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z")
	checkValue := map[string]reflect.Value{
		"loglevel":           reflect.ValueOf(""),
		"timeout":            reflect.ValueOf(parse.Duration(0)),
		"db":                 reflect.ValueOf(&DatabaseInfo{ServerInfo: ServerInfo{Watch: true, IP: "192.168.1.2", Load: 32, Load64: 64}, ConnectionMax: 3200000000, ConnectionMax64: 6400000000000000000}),
		"db.watch":           reflect.ValueOf(true),
		"db.ip":              reflect.ValueOf("192.168.1.2"),
		"db.load":            reflect.ValueOf(32),
		"db.load64":          reflect.ValueOf(int64(64)),
		"db.comax":           reflect.ValueOf(uint(3200000000)),
		"db.connectionmax64": reflect.ValueOf(uint64(6400000000000000000)),
		"owner":              reflect.ValueOf(&OwnerInfo{Name: nil, DateOfBirth: checkDob, Rate: 0.111, Servers: []ServerInfo{{Watch: false, IP: "192.168.1.2", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.3", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.4", Load: 0, Load64: 0}}}),
		"owner.name":         reflect.ValueOf(&checkStr),
		"owner.dob":          reflect.ValueOf(checkDob),
		"owner.rate":         reflect.ValueOf(float64(0.111)),
		"owner.servers":      reflect.ValueOf([]ServerInfo{{Watch: false, IP: "192.168.1.2", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.3", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.4", Load: 0, Load64: 0}}),
	}

	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 empty config but with default values on pointers
Test getDefaultValue on a empty config but with default values on pointers
// Test getDefaultValue on a empty config but with default values on pointers
func TestGetDefaultNoConfigAllDefault(t *testing.T) {
	config := &Configuration{}
	defPointerConfig := newDefaultPointersConfiguration()
	defaultValMap := make(map[string]reflect.Value)
	if err := getDefaultValue(reflect.ValueOf(config), reflect.ValueOf(defPointerConfig), defaultValMap, ""); err != nil {
		t.Fatal(err)
	}
	checkStr := "DefaultOwnerNamePointer"
	checkDob, _ := time.Parse(time.RFC3339, "1979-05-27T07:32:00Z")
	checkValue := map[string]reflect.Value{
		"loglevel":           reflect.ValueOf(""),
		"timeout":            reflect.ValueOf(parse.Duration(0)),
		"db":                 reflect.ValueOf(&DatabaseInfo{ServerInfo: ServerInfo{Watch: true, IP: "192.168.1.2", Load: 32, Load64: 64}, ConnectionMax: 3200000000, ConnectionMax64: 6400000000000000000}),
		"db.watch":           reflect.ValueOf(true),
		"db.ip":              reflect.ValueOf("192.168.1.2"),
		"db.load":            reflect.ValueOf(32),
		"db.load64":          reflect.ValueOf(int64(64)),
		"db.comax":           reflect.ValueOf(uint(3200000000)),
		"db.connectionmax64": reflect.ValueOf(uint64(6400000000000000000)),
		"owner":              reflect.ValueOf(&OwnerInfo{Name: nil, DateOfBirth: checkDob, Rate: 0.111, Servers: []ServerInfo{{Watch: false, IP: "192.168.1.2", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.3", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.4", Load: 0, Load64: 0}}}),
		"owner.name":         reflect.ValueOf(&checkStr),
		"owner.dob":          reflect.ValueOf(checkDob),
		"owner.rate":         reflect.ValueOf(float64(0.111)),
		"owner.servers":      reflect.ValueOf([]ServerInfo{{Watch: false, IP: "192.168.1.2", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.3", Load: 0, Load64: 0}, {Watch: false, IP: "192.168.1.4", Load: 0, Load64: 0}}),
	}
	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 TestGetDefaultNoConfigAllDefault ( t * testing . T ) { config := & Configuration { } defPointerConfig := newDefaultPointersConfiguration ( ) defaultValMap := make ( map [ string ] reflect . Value ) if err := getDefaultValue ( reflect . ValueOf ( config ) , reflect . ValueOf ( defPointerConfig ) , defaultValMap , " " ) ; err != nil { t . Fatal ( err ) } checkStr := " " checkDob , _ := time . Parse ( time . RFC3339 , " " ) checkValue := map [ string ] reflect . Value { " " : reflect . ValueOf ( " " ) , " " : reflect . ValueOf ( parse . Duration ( 0 ) ) , " " : reflect . ValueOf ( & DatabaseInfo { ServerInfo : ServerInfo { Watch : true , IP : " " , Load : 32 , Load64 : 64 } , ConnectionMax : 3200000000 , ConnectionMax64 : 6400000000000000000 } ) , " " : reflect . ValueOf ( true ) , " " : reflect . ValueOf ( " " ) , " " : reflect . ValueOf ( 32 ) , " " : reflect . ValueOf ( int64 ( 64 ) ) , " " : reflect . ValueOf ( uint ( 3200000000 ) ) , " " : reflect . ValueOf ( uint64 ( 6400000000000000000 ) ) , " " : reflect . ValueOf ( & OwnerInfo { Name : nil , DateOfBirth : checkDob , Rate : 0.111 , Servers : [ ] ServerInfo { { Watch : false , IP : " " , Load : 0 , Load64 : 0 } , { Watch : false , IP : " " , Load : 0 , Load64 : 0 } , { Watch : false , IP : " " , Load : 0 , Load64 : 0 } } } ) , " " : reflect . ValueOf ( & checkStr ) , " " : reflect . ValueOf ( checkDob ) , " " : reflect . ValueOf ( float64 ( 0.111 ) ) , " " : reflect . ValueOf ( [ ] ServerInfo { { Watch : false , IP : " " , Load : 0 , Load64 : 0 } , { Watch : false , IP : " " , Load : 0 , Load64 : 0 } , { Watch : false , IP : " " , Load : 0 , Load64 : 0 } } ) , } 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 empty config but with default values on pointers
Test getDefaultValue on a empty config but with default values on pointers