-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils_test.go
More file actions
43 lines (38 loc) · 783 Bytes
/
utils_test.go
File metadata and controls
43 lines (38 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (C) 2019 Audrius Butkevicius
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.
package recli
import (
"testing"
)
type Inner struct {
A string `default:"inner"`
B *DefaultStruct
}
type DefaultStruct struct {
A string `default:"outer"`
B []int `default:"10,20"`
C Inner
}
func TestSetDefault(t *testing.T) {
x := &DefaultStruct{}
x.C.B = x
err := setDefaults("default", x, nil)
if err != nil {
t.Error(err)
}
if x.A != "outer" {
t.Errorf("A")
}
if len(x.B) != 2 {
t.Errorf("B %d", len(x.B))
}
if x.C.A != "inner" {
t.Errorf("C.A")
}
if x.C.B.A != "outer" {
t.Errorf("A loop")
}
}