lib/weakhash, lib/model, cmd/syncthing: Decide if to use weakhash on startup (fixes #3938)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3949
This commit is contained in:
@@ -8,12 +8,21 @@ package util
|
||||
|
||||
import "testing"
|
||||
|
||||
type Defaulter struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
func (Defaulter) ParseDefault(v string) (interface{}, error) {
|
||||
return Defaulter{Value: v}, nil
|
||||
}
|
||||
|
||||
func TestSetDefaults(t *testing.T) {
|
||||
x := &struct {
|
||||
A string `default:"string"`
|
||||
B int `default:"2"`
|
||||
C float64 `default:"2.2"`
|
||||
D bool `default:"true"`
|
||||
A string `default:"string"`
|
||||
B int `default:"2"`
|
||||
C float64 `default:"2.2"`
|
||||
D bool `default:"true"`
|
||||
E Defaulter `default:"defaulter"`
|
||||
}{}
|
||||
|
||||
if x.A != "" {
|
||||
@@ -24,6 +33,8 @@ func TestSetDefaults(t *testing.T) {
|
||||
t.Errorf("float failed")
|
||||
} else if x.D {
|
||||
t.Errorf("bool failed")
|
||||
} else if x.E.Value != "" {
|
||||
t.Errorf("defaulter failed")
|
||||
}
|
||||
|
||||
if err := SetDefaults(x); err != nil {
|
||||
@@ -38,6 +49,8 @@ func TestSetDefaults(t *testing.T) {
|
||||
t.Errorf("float failed")
|
||||
} else if !x.D {
|
||||
t.Errorf("bool failed")
|
||||
} else if x.E.Value != "defaulter" {
|
||||
t.Errorf("defaulter failed")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user