mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 05:07:44 +08:00
gutil test 2019 06 15 14:20
This commit is contained in:
parent
407068a0bf
commit
a5ab2ba332
92
g/util/gutil/gutil_comparator_z_unit_test.go
Executable file
92
g/util/gutil/gutil_comparator_z_unit_test.go
Executable file
@ -0,0 +1,92 @@
|
||||
package gutil_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/g/test/gtest"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
)
|
||||
|
||||
func Test_ComparatorString(t *testing.T) {
|
||||
j := gutil.ComparatorString(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorInt(t *testing.T) {
|
||||
j := gutil.ComparatorInt(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorInt8(t *testing.T) {
|
||||
j := gutil.ComparatorInt8(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorInt16(t *testing.T) {
|
||||
j := gutil.ComparatorInt16(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorInt32(t *testing.T) {
|
||||
j := gutil.ComparatorInt32(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorInt64(t *testing.T) {
|
||||
j := gutil.ComparatorInt64(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorUint(t *testing.T) {
|
||||
j := gutil.ComparatorUint(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorUint8(t *testing.T) {
|
||||
j := gutil.ComparatorUint8(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorUint16(t *testing.T) {
|
||||
j := gutil.ComparatorUint16(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorUint32(t *testing.T) {
|
||||
j := gutil.ComparatorUint32(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorUint64(t *testing.T) {
|
||||
j := gutil.ComparatorUint64(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorFloat32(t *testing.T) {
|
||||
j := gutil.ComparatorFloat32(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorFloat64(t *testing.T) {
|
||||
j := gutil.ComparatorFloat64(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorByte(t *testing.T) {
|
||||
j := gutil.ComparatorByte(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorRune(t *testing.T) {
|
||||
j := gutil.ComparatorRune(1, 1)
|
||||
gtest.Assert(j, 0)
|
||||
}
|
||||
|
||||
func Test_ComparatorTime(t *testing.T) {
|
||||
j := gutil.ComparatorTime("2019-06-14", "2019-06-14")
|
||||
gtest.Assert(j, 0)
|
||||
k := gutil.ComparatorTime("2019-06-15", "2019-06-14")
|
||||
gtest.Assert(k, 1)
|
||||
l := gutil.ComparatorTime("2019-06-13", "2019-06-14")
|
||||
gtest.Assert(l, -1)
|
||||
}
|
68
g/util/gutil/gutil_z_unit_test.go
Executable file
68
g/util/gutil/gutil_z_unit_test.go
Executable file
@ -0,0 +1,68 @@
|
||||
package gutil_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/g/test/gtest"
|
||||
"github.com/gogf/gf/g/util/gutil"
|
||||
)
|
||||
|
||||
func Test_Dump(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
gutil.Dump(map[int]int{
|
||||
100: 100,
|
||||
})
|
||||
gtest.Assert("", "")
|
||||
})
|
||||
|
||||
gtest.Case(t, func() {
|
||||
gutil.Dump(map[string]interface{}{"": func() {}})
|
||||
gtest.Assert("", "")
|
||||
})
|
||||
|
||||
gtest.Case(t, func() {
|
||||
gutil.Dump([]byte("gutil Dump test"))
|
||||
gtest.Assert("", "")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PrintBacktrace(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
gutil.PrintBacktrace()
|
||||
gtest.Assert("", "")
|
||||
})
|
||||
}
|
||||
|
||||
func Test_TryCatch(t *testing.T) {
|
||||
|
||||
gutil.TryCatch(func() {
|
||||
}, func(err interface{}) {
|
||||
})
|
||||
gtest.Assert("", "")
|
||||
|
||||
gutil.TryCatch(func() {
|
||||
})
|
||||
gtest.Assert("", "")
|
||||
|
||||
gutil.TryCatch(func() {
|
||||
panic("gutil TryCatch test")
|
||||
}, func(err interface{}) {
|
||||
})
|
||||
gtest.Assert("", "")
|
||||
}
|
||||
|
||||
func Test_IsEmpty(t *testing.T) {
|
||||
gtest.Assert(gutil.IsEmpty(1), false)
|
||||
}
|
||||
|
||||
func Test_Throw(t *testing.T) {
|
||||
gtest.Case(t, func() {
|
||||
defer func() {
|
||||
if e := recover(); e != nil {
|
||||
gtest.Assert(e, "gutil Throw test")
|
||||
}
|
||||
}()
|
||||
|
||||
gutil.Throw("gutil Throw test")
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user