代码拉取完成,页面将自动刷新
// ⚡️ Fiber is an Express inspired web framework written in Go with ☕️
// 🤖 Github Repository: https://gitee.com/azhai/fiber-u8l
// 📌 API Documentation: https://docs.gofiber.io
package utils
import (
"bytes"
"fmt"
"log"
"path/filepath"
"reflect"
"runtime"
"testing"
"text/tabwriter"
)
// AssertEqual checks if values are equal
func AssertEqual(t testing.TB, expected interface{}, actual interface{}, description ...string) {
if reflect.DeepEqual(expected, actual) {
return
}
var aType = "<nil>"
var bType = "<nil>"
if reflect.ValueOf(expected).IsValid() {
aType = reflect.TypeOf(expected).Name()
}
if reflect.ValueOf(actual).IsValid() {
bType = reflect.TypeOf(actual).Name()
}
testName := "AssertEqual"
if t != nil {
testName = t.Name()
}
_, file, line, _ := runtime.Caller(1)
var buf bytes.Buffer
w := tabwriter.NewWriter(&buf, 0, 0, 5, ' ', 0)
fmt.Fprintf(w, "\nTest:\t%s", testName)
fmt.Fprintf(w, "\nTrace:\t%s:%d", filepath.Base(file), line)
fmt.Fprintf(w, "\nError:\tNot equal")
fmt.Fprintf(w, "\nExpect:\t%v\t[%s]", expected, aType)
fmt.Fprintf(w, "\nResult:\t%v\t[%s]", actual, bType)
if len(description) > 0 {
fmt.Fprintf(w, "\nDescription:\t%s", description[0])
}
result := ""
if err := w.Flush(); err != nil {
result = err.Error()
} else {
result = buf.String()
}
if t != nil {
t.Fatal(result)
} else {
log.Fatal(result)
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。