mirror of
https://gitee.com/johng/gf.git
synced 2024-12-02 04:07:47 +08:00
增加用例覆盖率
This commit is contained in:
parent
da7eac03ad
commit
d5d56e51d7
@ -99,8 +99,6 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
|
||||
}
|
||||
m3, ok := m2.(map[string]interface{})
|
||||
if !ok {
|
||||
// intermediate key is a value
|
||||
// => replace with a new map
|
||||
m3 = make(map[string]interface{})
|
||||
m[k] = m3
|
||||
}
|
||||
@ -113,12 +111,8 @@ func deepSearch(m map[string]interface{}, path []string) map[string]interface{}
|
||||
// flattenAndMergeMap recursively flattens the given map into a new map
|
||||
func flattenAndMergeMap(shadow map[string]interface{}, m map[string]interface{}, prefix string, delimiter string) map[string]interface{} {
|
||||
if shadow != nil && prefix != "" && shadow[prefix] != nil {
|
||||
// prefix is shadowed => nothing more to flatten
|
||||
return shadow
|
||||
}
|
||||
if shadow == nil {
|
||||
shadow = make(map[string]interface{})
|
||||
}
|
||||
|
||||
var m2 map[string]interface{}
|
||||
if prefix != "" {
|
||||
|
@ -19,9 +19,13 @@ import (
|
||||
var pStr string = `
|
||||
# 模板引擎目录
|
||||
viewpath = "/home/www/templates/"
|
||||
# MySQL数据库配置
|
||||
# redis数据库配置
|
||||
redis.disk = "127.0.0.1:6379,0"
|
||||
redis.cache = "127.0.0.1:6379,1"
|
||||
#SQL配置
|
||||
sql.mysql.0.type = mysql
|
||||
sql.mysql.0.ip = 127.0.0.1
|
||||
sql.mysql.0.user = root
|
||||
`
|
||||
var errorTests = []struct {
|
||||
input, msg string
|
||||
@ -114,4 +118,14 @@ func TestToJson(t *testing.T) {
|
||||
}
|
||||
t.Assert(jsonPr, expectJson)
|
||||
})
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
for _, v := range errorTests {
|
||||
_, err := gproperties.ToJson(([]byte)(v.input))
|
||||
if err == nil {
|
||||
t.Errorf("encode should be failed. %v", err)
|
||||
return
|
||||
}
|
||||
t.AssertIN(`Lib magiconair load Properties data failed.`, strings.Split(err.Error(), ":"))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user