From abdf8e696c1bca8ec2cb0760f1c37fe4e07c267c Mon Sep 17 00:00:00 2001 From: hailaz <739476267@qq.com> Date: Wed, 12 Jun 2019 17:52:30 +0800 Subject: [PATCH] gtype unit test use AssertEQ replace Assert. --- g/container/gtype/gtype_z_unit_test.go | 100 ++++++++++++------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/g/container/gtype/gtype_z_unit_test.go b/g/container/gtype/gtype_z_unit_test.go index 3b7f0a5e1..9870ed8c6 100644 --- a/g/container/gtype/gtype_z_unit_test.go +++ b/g/container/gtype/gtype_z_unit_test.go @@ -17,17 +17,17 @@ func Test_Bool(t *testing.T) { gtest.Case(t, func() { i := gtype.NewBool(true) iClone := i.Clone() - gtest.Assert(iClone.Set(false), true) - gtest.Assert(iClone.Val(), false) + gtest.AssertEQ(iClone.Set(false), true) + gtest.AssertEQ(iClone.Val(), false) i1 := gtype.NewBool(false) iClone1 := i1.Clone() - gtest.Assert(iClone1.Set(true), false) - gtest.Assert(iClone1.Val(), true) + gtest.AssertEQ(iClone1.Set(true), false) + gtest.AssertEQ(iClone1.Val(), true) //空参测试 i2 := gtype.NewBool() - gtest.Assert(i2.Val(), false) + gtest.AssertEQ(i2.Val(), false) }) } @@ -37,8 +37,8 @@ func Test_Byte(t *testing.T) { addTimes := 127 i := gtype.NewByte(byte(0)) iClone := i.Clone() - gtest.Assert(iClone.Set(byte(1)), byte(0)) - gtest.Assert(iClone.Val(), byte(1)) + gtest.AssertEQ(iClone.Set(byte(1)), byte(0)) + gtest.AssertEQ(iClone.Val(), byte(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -47,11 +47,11 @@ func Test_Byte(t *testing.T) { }() } wg.Wait() - gtest.Assert(byte(addTimes), i.Val()) + gtest.AssertEQ(byte(addTimes), i.Val()) //空参测试 i1 := gtype.NewByte() - gtest.Assert(i1.Val(), byte(0)) + gtest.AssertEQ(i1.Val(), byte(0)) }) } @@ -59,12 +59,12 @@ func Test_Bytes(t *testing.T) { gtest.Case(t, func() { i := gtype.NewBytes([]byte("abc")) iClone := i.Clone() - gtest.Assert(iClone.Set([]byte("123")), []byte("abc")) - gtest.Assert(iClone.Val(), []byte("123")) + gtest.AssertEQ(iClone.Set([]byte("123")), []byte("abc")) + gtest.AssertEQ(iClone.Val(), []byte("123")) //空参测试 i1 := gtype.NewBytes() - gtest.Assert(i1.Val(), nil) + gtest.AssertEQ(i1.Val(), nil) }) } @@ -72,12 +72,12 @@ func Test_String(t *testing.T) { gtest.Case(t, func() { i := gtype.NewString("abc") iClone := i.Clone() - gtest.Assert(iClone.Set("123"), "abc") - gtest.Assert(iClone.Val(), "123") + gtest.AssertEQ(iClone.Set("123"), "abc") + gtest.AssertEQ(iClone.Val(), "123") //空参测试 i1 := gtype.NewString() - gtest.Assert(i1.Val(), "") + gtest.AssertEQ(i1.Val(), "") }) } @@ -87,12 +87,12 @@ func Test_Interface(t *testing.T) { t1 := Temp{Name: "gf", Age: 19} i := gtype.New(t) iClone := i.Clone() - gtest.Assert(iClone.Set(t1), t) - gtest.Assert(iClone.Val().(Temp), t1) + gtest.AssertEQ(iClone.Set(t1), t) + gtest.AssertEQ(iClone.Val().(Temp), t1) //空参测试 i1 := gtype.New() - gtest.Assert(i1.Val(), nil) + gtest.AssertEQ(i1.Val(), nil) }) } @@ -102,8 +102,8 @@ func Test_Float32(t *testing.T) { //addTimes := 100 i := gtype.NewFloat32(0) iClone := i.Clone() - gtest.Assert(iClone.Set(0.1), 0.0) - gtest.Assert(iClone.Val(), 0.1) + gtest.AssertEQ(iClone.Set(0.1), float32(0)) + gtest.AssertEQ(iClone.Val(), float32(0.1)) // for index := 0; index < addTimes; index++ { // wg.Add(1) // go func() { @@ -113,11 +113,11 @@ func Test_Float32(t *testing.T) { // }() // } // wg.Wait() - // gtest.Assert(100.0, i.Val()) + // gtest.AssertEQ(100.0, i.Val()) //空参测试 i1 := gtype.NewFloat32() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), float32(0)) }) } @@ -127,8 +127,8 @@ func Test_Float64(t *testing.T) { //addTimes := 100 i := gtype.NewFloat64(0) iClone := i.Clone() - gtest.Assert(iClone.Set(0.1), 0.0) - gtest.Assert(iClone.Val(), 0.1) + gtest.AssertEQ(iClone.Set(0.1), float64(0)) + gtest.AssertEQ(iClone.Val(), float64(0.1)) // for index := 0; index < addTimes; index++ { // wg.Add(1) // go func() { @@ -138,11 +138,11 @@ func Test_Float64(t *testing.T) { // }() // } // wg.Wait() - // gtest.Assert(100.0, i.Val()) + // gtest.AssertEQ(100.0, i.Val()) //空参测试 i1 := gtype.NewFloat64() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), float64(0)) }) } @@ -152,8 +152,8 @@ func Test_Int(t *testing.T) { addTimes := 1000 i := gtype.NewInt(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), 0) + gtest.AssertEQ(iClone.Val(), 1) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -162,11 +162,11 @@ func Test_Int(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(addTimes, i.Val()) //空参测试 i1 := gtype.NewInt() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), 0) }) } @@ -176,8 +176,8 @@ func Test_Int32(t *testing.T) { addTimes := 1000 i := gtype.NewInt32(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), int32(0)) + gtest.AssertEQ(iClone.Val(), int32(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -186,11 +186,11 @@ func Test_Int32(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(int32(addTimes), i.Val()) //空参测试 i1 := gtype.NewInt32() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), int32(0)) }) } @@ -200,8 +200,8 @@ func Test_Int64(t *testing.T) { addTimes := 1000 i := gtype.NewInt64(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), int64(0)) + gtest.AssertEQ(iClone.Val(), int64(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -210,11 +210,11 @@ func Test_Int64(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(int64(addTimes), i.Val()) //空参测试 i1 := gtype.NewInt64() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), int64(0)) }) } @@ -224,8 +224,8 @@ func Test_Uint(t *testing.T) { addTimes := 1000 i := gtype.NewUint(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), uint(0)) + gtest.AssertEQ(iClone.Val(), uint(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -234,11 +234,11 @@ func Test_Uint(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(uint(addTimes), i.Val()) //空参测试 i1 := gtype.NewUint() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), uint(0)) }) } @@ -248,8 +248,8 @@ func Test_Uint32(t *testing.T) { addTimes := 1000 i := gtype.NewUint32(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), uint32(0)) + gtest.AssertEQ(iClone.Val(), uint32(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -258,11 +258,11 @@ func Test_Uint32(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(uint32(addTimes), i.Val()) //空参测试 i1 := gtype.NewUint32() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), uint32(0)) }) } @@ -272,8 +272,8 @@ func Test_Uint64(t *testing.T) { addTimes := 1000 i := gtype.NewUint64(0) iClone := i.Clone() - gtest.Assert(iClone.Set(1), 0) - gtest.Assert(iClone.Val(), 1) + gtest.AssertEQ(iClone.Set(1), uint64(0)) + gtest.AssertEQ(iClone.Val(), uint64(1)) for index := 0; index < addTimes; index++ { wg.Add(1) go func() { @@ -282,10 +282,10 @@ func Test_Uint64(t *testing.T) { }() } wg.Wait() - gtest.Assert(addTimes, i.Val()) + gtest.AssertEQ(uint64(addTimes), i.Val()) //空参测试 i1 := gtype.NewUint64() - gtest.Assert(i1.Val(), 0) + gtest.AssertEQ(i1.Val(), uint64(0)) }) }