mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-28 19:47:14 +08:00
fix: failed to assert when int is compared with int64 #1232
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@@ -198,6 +199,39 @@ func Interface2Float64(i interface{}) (float64, error) {
|
||||
return 0, errors.New("failed to convert interface to float64")
|
||||
}
|
||||
|
||||
func TypeNormalization(raw interface{}) interface{} {
|
||||
rawValue := reflect.ValueOf(raw)
|
||||
switch rawValue.Kind() {
|
||||
case reflect.Int:
|
||||
return rawValue.Int()
|
||||
case reflect.Int8:
|
||||
return rawValue.Int()
|
||||
case reflect.Int16:
|
||||
return rawValue.Int()
|
||||
case reflect.Int32:
|
||||
return rawValue.Int()
|
||||
case reflect.Float32:
|
||||
return rawValue.Float()
|
||||
case reflect.Uint:
|
||||
return rawValue.Uint()
|
||||
case reflect.Uint8:
|
||||
return rawValue.Uint()
|
||||
case reflect.Uint16:
|
||||
return rawValue.Uint()
|
||||
case reflect.Uint32:
|
||||
return rawValue.Uint()
|
||||
default:
|
||||
return raw
|
||||
}
|
||||
}
|
||||
|
||||
func InterfaceType(raw interface{}) string {
|
||||
if raw == nil {
|
||||
return ""
|
||||
}
|
||||
return reflect.TypeOf(raw).String()
|
||||
}
|
||||
|
||||
var ErrUnsupportedFileExt = fmt.Errorf("unsupported file extension")
|
||||
|
||||
// LoadFile loads file content with file extension and assigns to structObj
|
||||
|
||||
Reference in New Issue
Block a user