1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 03:47:04 +00:00
Former-commit-id: 00b5b1ed0daa310912fcb02c96861d049909020b
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-06-23 18:45:50 +03:00
parent 208e593df7
commit edbb128c68
2 changed files with 42 additions and 3 deletions

View File

@@ -450,4 +450,22 @@ func TestConvertBuilderFunc(t *testing.T) {
if !evalFunc([]string{"1", "[name1,name2]"}).Call([]reflect.Value{reflect.ValueOf("ok")})[0].Interface().(bool) {
t.Fatalf("failed, it should fail already")
}
fnSimplify := func(requestParamValue string) bool {
return requestParamValue == "kataras"
}
evalFunc = convertBuilderFunc(fnSimplify)
if !evalFunc([]string{}).Call([]reflect.Value{reflect.ValueOf("kataras")})[0].Interface().(bool) {
t.Fatalf("it should pass, the combile arguments are empty and the given request value is the expected one")
}
defer func() {
if r := recover(); r == nil {
t.Fatalf("it should panic, the combile arguments are more than one")
}
}()
// should panic.
evalFunc([]string{"1"}).Call([]reflect.Value{reflect.ValueOf("kataras")})
}