1
0
Fork 0
mirror of https://github.com/Luzifer/rconfig.git synced 2024-11-09 16:30:04 +00:00
rconfig/sub-struct_test.go

31 lines
526 B
Go
Raw Permalink Normal View History

2015-09-08 20:07:40 +00:00
package rconfig
import (
"testing"
2015-09-08 20:07:40 +00:00
)
func TestSubStructParsing(t *testing.T) {
2015-09-08 20:07:40 +00:00
var (
args = []string{}
cfg struct {
Test string `default:"blubb"`
Sub struct {
Test string `default:"Hallo"`
}
}
)
2015-09-08 20:07:40 +00:00
if err := parse(&cfg, args); err != nil {
t.Fatalf("Parsing options caused error: %s", err)
}
2015-09-08 20:07:40 +00:00
for _, test := range [][2]interface{}{
{cfg.Test, "blubb"},
{cfg.Sub.Test, "Hallo"},
} {
if test[0] != test[1] {
t.Errorf("Expected value does not match: %#v != %#v", test[0], test[1])
}
}
}