forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
column_test.go
52 lines (45 loc) · 1.99 KB
/
column_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
// Copyright 2019 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// See the License for the specific language governing permissions and
// limitations under the License.
package server
import (
. "github.com/pingcap/check"
"github.com/pingcap/parser/mysql"
)
type ColumnTestSuite struct {
}
var _ = Suite(new(ColumnTestSuite))
func (s ColumnTestSuite) TestDumpColumn(c *C) {
info := ColumnInfo{
Schema: "testSchema",
Table: "testTable",
OrgTable: "testOrgTable",
Name: "testName",
OrgName: "testOrgName",
ColumnLength: 1,
Charset: 106,
Flag: 0,
Decimal: 1,
Type: 14,
DefaultValueLength: 2,
DefaultValue: []byte{5, 2},
}
r := info.Dump(nil)
exp := []byte{0x3, 0x64, 0x65, 0x66, 0xa, 0x74, 0x65, 0x73, 0x74, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x9, 0x74, 0x65, 0x73, 0x74, 0x54, 0x61, 0x62, 0x6c, 0x65, 0xc, 0x74, 0x65, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x8, 0x74, 0x65, 0x73, 0x74, 0x4e, 0x61, 0x6d, 0x65, 0xb, 0x74, 0x65, 0x73, 0x74, 0x4f, 0x72, 0x67, 0x4e, 0x61, 0x6d, 0x65, 0xc, 0x6a, 0x0, 0x1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x1, 0x0, 0x0, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5, 0x2}
c.Assert(r, DeepEquals, exp)
c.Assert(dumpFlag(mysql.TypeSet, 0), Equals, uint16(mysql.SetFlag))
c.Assert(dumpFlag(mysql.TypeEnum, 0), Equals, uint16(mysql.EnumFlag))
c.Assert(dumpFlag(mysql.TypeString, 0), Equals, uint16(0))
c.Assert(dumpType(mysql.TypeSet), Equals, mysql.TypeString)
c.Assert(dumpType(mysql.TypeEnum), Equals, mysql.TypeString)
c.Assert(dumpType(mysql.TypeBit), Equals, mysql.TypeBit)
}