Skip to content

Commit

Permalink
Merge pull request #306 from taosdata/fix/xftan/stmt-test
Browse files Browse the repository at this point in the history
test: fix stmt bind geometry test
  • Loading branch information
huskar-t authored Nov 15, 2024
2 parents 11d5adc + 619c863 commit f9a414c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 29 deletions.
57 changes: 29 additions & 28 deletions wrapper/cgo/handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package cgo
import (
"reflect"
"testing"

"github.com/stretchr/testify/assert"
)

// @author: xftan
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion wrapper/stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f9a414c

Please sign in to comment.