-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_test.go
53 lines (46 loc) · 1.02 KB
/
json_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
package db
import (
"fmt"
"regexp"
"testing"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/wrapperspb"
)
func TestCast(t *testing.T) {
fmt.Println("beign")
//var msg proto.Message
msg := wrapperspb.String("abc")
a := msg.ProtoReflect().New()
aa := proto.Clone(msg)
fmt.Println(msg, a, aa)
t.Error("done")
}
func TestPrimaryKey(t *testing.T) {
//checkTable("test")
//DB.Exec("drop table test")
}
func TestJsonEscape(t *testing.T) {
goods := Goods{Id: "iii"}
goods.Desc = "~!@#$%^&*()_+{}|:\";',./<>?'"
//fmt.Println(ToJSON(goods))
// if err := Insert("test1", goods); err != nil {
// t.Error(err)
// }
var g1 Goods
// if err := GetById("test1", "iii", &g1); err != nil {
// t.Error(err)
// }
fmt.Println(g1.Desc)
//DB.Exec("drop table test1")
t.Error("done")
}
type Goods struct {
Id string `json:"id,omitempty"`
Name string
Desc string
}
func TestRegexp(t *testing.T) {
matched, err := regexp.MatchString("s.*a.*od", "seafoodrtt")
fmt.Println(matched, err)
t.Error("end")
}