Add two builtin name getter

This commit is contained in:
Unknwon
2015-01-02 01:00:31 +08:00
parent 8ca0fa127b
commit afcdaa289f
2 changed files with 59 additions and 2 deletions
+19
View File
@@ -162,3 +162,22 @@ func Test_Struct(t *testing.T) {
So(MapTo(&emptySlice{}, []byte(_INVALID_DATA_CONF_STRUCT)), ShouldBeNil)
})
}
type testGetter struct {
PackageName string
}
func Test_NameGetter(t *testing.T) {
Convey("Test name getters", t, func() {
So(MapToGetter(&testGetter{}, TitleUnderscore, []byte("packag_name=ini")), ShouldBeNil)
cfg, err := Load([]byte("PACKAGE_NAME=ini"))
So(err, ShouldBeNil)
So(cfg, ShouldNotBeNil)
cfg.NameGetter = AllCapsUnderscore
tg := new(testGetter)
So(cfg.MapTo(tg), ShouldBeNil)
So(tg.PackageName, ShouldEqual, "ini")
})
}