From d9e5c616b3b824100e9bdac7f6c131a45ec02f63 Mon Sep 17 00:00:00 2001 From: t_max <1172915550@qq.com> Date: Tue, 12 Nov 2024 10:36:15 +0800 Subject: [PATCH 1/2] test: fix stmt bind geometry test --- wrapper/stmt_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wrapper/stmt_test.go b/wrapper/stmt_test.go index b771ddd..557b10d 100644 --- a/wrapper/stmt_test.go +++ b/wrapper/stmt_test.go @@ -154,7 +154,7 @@ func TestStmt(t *testing.T) { params: [][]driver.Value{{taosTypes.TaosTimestamp{T: now, Precision: common.PrecisionMilliSecond}}, {taosTypes.TaosGeometry{0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40}}}, bindType: []*taosTypes.ColumnType{{Type: taosTypes.TaosTimestampType}, { Type: taosTypes.TaosGeometryType, - MaxLen: 3, + MaxLen: 100, }}, expectValue: []byte{0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x59, 0x40}, }, //3 From 619c863023ed00f2f20e91fa6e0960aa6f789aad Mon Sep 17 00:00:00 2001 From: t_max <1172915550@qq.com> Date: Tue, 12 Nov 2024 11:03:26 +0800 Subject: [PATCH 2/2] test: add cgo test --- wrapper/cgo/handle_test.go | 57 +++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/wrapper/cgo/handle_test.go b/wrapper/cgo/handle_test.go index 89bfd31..46cdc52 100644 --- a/wrapper/cgo/handle_test.go +++ b/wrapper/cgo/handle_test.go @@ -7,6 +7,8 @@ package cgo import ( "reflect" "testing" + + "github.com/stretchr/testify/assert" ) // @author: xftan @@ -56,34 +58,33 @@ func TestHandle(t *testing.T) { } } -//func TestInvalidHandle(t *testing.T) { -// t.Run("zero", func(t *testing.T) { -// h := Handle(0) -// -// defer func() { -// if r := recover(); r != nil { -// return -// } -// t.Fatalf("Delete of zero handle did not trigger a panic") -// }() -// -// h.Delete() -// }) -// -// t.Run("invalid", func(t *testing.T) { -// h := NewHandle(42) -// -// defer func() { -// if r := recover(); r != nil { -// h.Delete() -// return -// } -// t.Fatalf("Invalid handle did not trigger a panic") -// }() -// -// Handle(h + 1).Delete() -// }) -//} +func TestPointer(t *testing.T) { + v := 42 + h := NewHandle(&v) + p := h.Pointer() + assert.Equal(t, *(*Handle)(p), h) + h.Delete() + defer func() { + if r := recover(); r != nil { + return + } + t.Fatalf("Pointer should panic") + }() + h.Pointer() +} + +func TestInvalidValue(t *testing.T) { + v := 42 + h := NewHandle(&v) + h.Delete() + defer func() { + if r := recover(); r != nil { + return + } + t.Fatalf("Value should panic") + }() + h.Value() +} func BenchmarkHandle(b *testing.B) { b.Run("non-concurrent", func(b *testing.B) {