forked from zhuxiujia/GoMybatis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoMybatisSqlArgTypeConvert_test.go
67 lines (63 loc) · 1.85 KB
/
GoMybatisSqlArgTypeConvert_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package GoMybatis
import (
"fmt"
"testing"
"time"
)
func Test_SqlArgTypeConvert(t *testing.T) {
var a = true
var convertResult = GoMybatisSqlArgTypeConvert{}.Convert(a)
if convertResult != "true" {
t.Fatal(`Test_Adapter fail convertResult != true`)
}
fmt.Println(convertResult)
convertResult = GoMybatisSqlArgTypeConvert{}.Convert(1)
if convertResult != "1" {
t.Fatal(`Test_Adapter fail convertResult != 1`)
}
fmt.Println(convertResult)
var now = time.Now()
convertResult = GoMybatisSqlArgTypeConvert{}.Convert(now)
if convertResult != "'"+now.Format(Adapter_FormateDate)+"'" {
t.Fatal(`Test_Adapter fail convertResult != 2019-05-10 11:09:01`)
}
fmt.Println(convertResult)
convertResult = GoMybatisSqlArgTypeConvert{}.Convert("string")
if convertResult != "'string'" {
t.Fatal(`Test_Adapter fail convertResult != string`)
}
fmt.Println(convertResult)
}
func Test_SqlArgTypeConvert_NoType(t *testing.T) {
var a = true
var convertResult = GoMybatisSqlArgTypeConvert{}.Convert(a)
if convertResult == "" {
t.Fatal(`Test_Adapter fail convertResult != true`)
}
fmt.Println(convertResult)
convertResult = GoMybatisSqlArgTypeConvert{}.Convert(1)
if convertResult == "" {
t.Fatal(`Test_Adapter fail convertResult != 1`)
}
fmt.Println(convertResult)
convertResult = GoMybatisSqlArgTypeConvert{}.Convert(time.Now())
if convertResult == "" {
t.Fatal(`Test_Adapter fail convertResult != time.Time`)
}
fmt.Println(convertResult)
convertResult = GoMybatisSqlArgTypeConvert{}.Convert("string")
if convertResult == "" {
t.Fatal(`Test_Adapter fail convertResult != string`)
}
fmt.Println(convertResult)
}
func BenchmarkGoMybatisSqlArgTypeConvert_Convert(b *testing.B) {
b.StopTimer()
b.StartTimer()
for i := 0; i < b.N; i++ {
var convertResult = GoMybatisSqlArgTypeConvert{}.Convert(1)
if convertResult == "" {
b.Fatal("convert fail!")
}
}
}