本文整理汇总了Golang中github.com/Jxck/assertion.Equal函数的典型用法代码示例。如果您正苦于以下问题:Golang Equal函数的具体用法?Golang Equal怎么用?Golang Equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Equal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestStringLiteralDecode
func TestStringLiteralDecode(t *testing.T) {
// D.2.1. Literal Header Field with Indexing
var indexing Indexing = WITH
var name, value string = "custom-key", "custom-header"
buf := []byte{
0x40, 0x0a,
0x63, 0x75,
0x73, 0x74,
0x6f, 0x6d,
0x2d, 0x6b,
0x65, 0x79,
0x0d, 0x63,
0x75, 0x73,
0x74, 0x6f,
0x6d, 0x2d,
0x68, 0x65,
0x61, 0x64,
0x65, 0x72,
}
sw := swrap.New(buf)
decoded := DecodeHeader(&sw)
frame, ok := decoded.(*StringLiteral)
assert.Equal(t, ok, true)
expected := NewStringLiteral(indexing, name, value)
assert.Equal(t, frame, expected)
}
开发者ID:Jxck,项目名称:hpack,代码行数:28,代码来源:decoder_test.go
示例2: TestSettingsCase
func TestSettingsCase(t *testing.T) {
var c TestCase
framecase := []byte(`{
"error": null,
"wire": "00000C040000000000000100002000000300001388",
"frame": {
"length": 12,
"frame_payload": {
"settings": [
[
1,
8192
],
[
3,
5000
]
],
"padding_length": null,
"padding": null
},
"flags": 0,
"stream_identifier": 0,
"type": 4
},
"draft": 14,
"description": "noraml rst stream frame"
}`)
err := json.Unmarshal(framecase, &c)
if err != nil {
t.Fatal(err)
}
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
settings := map[SettingsID]int32{
1: 8192,
3: 5000,
}
// compare struct
expected := NewSettingsFrame(flags, streamId, settings)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:58,代码来源:frame_test.go
示例3: TestHeadersPriorityCase
func TestHeadersPriorityCase(t *testing.T) {
var c TestCase
var p HeadersPriorityPayload
framecase := []byte(`{
"error": null,
"wire": "000023012800000003108000001409746869732069732064756D6D79546869732069732070616464696E672E",
"frame": {
"length": 35,
"frame_payload": {
"priority": {
"stream_dependency": 20,
"weight": 10,
"exclusive": true
},
"header_block_fragment": "this is dummy",
"padding_length": 16,
"padding": "This is padding."
},
"flags": 40,
"stream_identifier": 3,
"type": 1
},
"draft": 14,
"description": "noraml headers frame including priority"
}`)
// ignore error
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
hb := []byte(p.HeaderBlockFragment)
padding := []byte(p.Padding)
dependencyTree := &DependencyTree{
Exclusive: p.Priority.Exclusive,
StreamDependency: p.Priority.StreamDependency,
Weight: p.Priority.Weight,
}
// compare struct
expected := NewHeadersFrame(flags, streamId, dependencyTree, hb, padding)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:56,代码来源:frame_test.go
示例4: TestIndexedHeaderDecode
func TestIndexedHeaderDecode(t *testing.T) {
// D.2.4. Indexed Header Field
var index uint32 = 2
buf := []byte{0x82}
sw := swrap.New(buf)
decoded := DecodeHeader(&sw)
frame, ok := decoded.(*IndexedHeader)
assert.Equal(t, ok, true)
assert.Equal(t, frame.Index, index)
}
开发者ID:Jxck,项目名称:hpack,代码行数:11,代码来源:decoder_test.go
示例5: TestNewIndexedLiteral
func TestNewIndexedLiteral(t *testing.T) {
var indexing Indexing = WITH
var index uint32 = 10
var value string = "var"
var frame *IndexedLiteral = NewIndexedLiteral(indexing, index, value)
assert.Equal(t, frame.Indexing, indexing)
assert.Equal(t, frame.Index, index)
assert.Equal(t, frame.ValueLength, uint32(len(value)))
assert.Equal(t, frame.ValueString, value)
}
开发者ID:Jxck,项目名称:hpack,代码行数:11,代码来源:type_test.go
示例6: TestNewStringLiteral
func TestNewStringLiteral(t *testing.T) {
var indexing Indexing = WITH
var name string = "foo"
var value string = "var"
var frame *StringLiteral = NewStringLiteral(indexing, name, value)
assert.Equal(t, frame.Indexing, indexing)
assert.Equal(t, frame.NameLength, uint32(len(name)))
assert.Equal(t, frame.NameString, name)
assert.Equal(t, frame.ValueLength, uint32(len(value)))
assert.Equal(t, frame.ValueString, value)
}
开发者ID:Jxck,项目名称:hpack,代码行数:12,代码来源:type_test.go
示例7: TestPushPromiseCase
// PUSH_PROMISE Frame
func TestPushPromiseCase(t *testing.T) {
var c TestCase
var p PushPromisePayload
framecase := []byte(`{
"error": null,
"wire": "000018050800000009060000000B746869732069732064756D6D79486F77647921",
"frame": {
"length": 24,
"frame_payload": {
"header_block_fragment": "this is dummy",
"padding_length": 6,
"promised_stream_id": 11,
"padding": "Howdy!"
},
"flags": 8,
"stream_identifier": 9,
"type": 5
},
"draft": 14,
"description": "noraml push promise frame"
}`)
// ignore error
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
promisedStreamId := p.PromisedStreamID
headerBlockFragment := []byte(p.HeaderBlockFragment)
padding := []byte(p.Padding)
// compare struct
expected := NewPushPromiseFrame(flags, streamId, promisedStreamId, headerBlockFragment, padding)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:49,代码来源:frame_test.go
示例8: TestDynamicTableSizeLen
func TestDynamicTableSizeLen(t *testing.T) {
ht := DynamicTable{
DEFAULT_HEADER_TABLE_SIZE,
[]*HeaderField{
NewHeaderField("1234", "1234"),
NewHeaderField("1234", "1234"),
NewHeaderField("1234", "1234"),
NewHeaderField("1234", "1234"),
NewHeaderField("1234", "1234"),
},
}
var actual uint32 = 200
assert.Equal(t, ht.Size(), actual)
assert.Equal(t, ht.Len(), 5)
}
开发者ID:Jxck,项目名称:hpack,代码行数:16,代码来源:dynamic_table_test.go
示例9: TestStringLiteralEncode
func TestStringLiteralEncode(t *testing.T) {
// D.2.1. Literal Header Field with Indexing
var indexing Indexing = WITH
var name, value string = "custom-key", "custom-header"
buf := []byte{
0x40, 0x0a,
0x63, 0x75,
0x73, 0x74,
0x6f, 0x6d,
0x2d, 0x6b,
0x65, 0x79,
0x0d, 0x63,
0x75, 0x73,
0x74, 0x6f,
0x6d, 0x2d,
0x68, 0x65,
0x61, 0x64,
0x65, 0x72,
}
frame := NewStringLiteral(indexing, name, value)
actual := frame.Encode()
assert.Equal(t, actual.Bytes(), buf)
}
开发者ID:Jxck,项目名称:hpack,代码行数:25,代码来源:encoder_test.go
示例10: TestGoAwayCase
func TestGoAwayCase(t *testing.T) {
var c TestCase
var p GoAwayPayload
framecase := []byte(`{
"error": null,
"wire": "0000170700000000000000001E00000009687061636B2069732062726F6B656E",
"frame": {
"length": 23,
"frame_payload": {
"error_code": 9,
"additional_debug_data": "hpack is broken",
"padding_length": null,
"last_stream_id": 30,
"padding": null
},
"flags": 0,
"stream_identifier": 0,
"type": 7
},
"draft": 14,
"description": "normal goaway frame"
}`)
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
streamId := c.Frame.StreamId
lastStreamId := p.LastStreamID
errorCode := p.ErrorCode
additional := []byte(p.AdditionalDebugData)
// compare struct
expected := NewGoAwayFrame(streamId, lastStreamId, errorCode, additional)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:47,代码来源:frame_test.go
示例11: TestDataCase
func TestDataCase(t *testing.T) {
var c TestCase
var p DataPayload
framecase := []byte(`{
"error": null,
"wire": "0000140008000000020648656C6C6F2C20776F726C6421486F77647921",
"frame": {
"length": 20,
"frame_payload": {
"data": "Hello, world!",
"padding_length": 6,
"padding": "Howdy!"
},
"flags": 8,
"stream_identifier": 2,
"type": 0
},
"draft": 14,
"description": "noraml data frame"
}`)
// ignore error
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
data := []byte(p.Data)
padding := []byte(p.Padding)
// compare struct
expected := NewDataFrame(flags, streamId, data, padding)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
_ = actual
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:47,代码来源:frame_test.go
示例12: TestNewIndexedHeader
func TestNewIndexedHeader(t *testing.T) {
var index uint32 = 10
var frame *IndexedHeader
frame = NewIndexedHeader(index)
actual, expected := frame.Index, index
assert.Equal(t, actual, expected)
}
开发者ID:Jxck,项目名称:hpack,代码行数:8,代码来源:type_test.go
示例13: TestHeadersCase
func TestHeadersCase(t *testing.T) {
var c TestCase
var p HeadersPayload
framecase := []byte(`{
"error": null,
"wire": "00000D010000000001746869732069732064756D6D79",
"frame": {
"length": 13,
"frame_payload": {
"priority": null,
"header_block_fragment": "this is dummy",
"padding_length": null,
"padding": null
},
"flags": 0,
"stream_identifier": 1,
"type": 1
},
"draft": 14,
"description": "noraml headers frame"
}`)
// ignore error
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
headerBlockFragment := []byte(p.HeaderBlockFragment)
// compare struct
expected := NewHeadersFrame(flags, streamId, nil, headerBlockFragment, nil)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:46,代码来源:frame_test.go
示例14: TestDecode
func TestDecode(t *testing.T) {
for _, tc := range testCase {
expected := tc.str
code := toHexBytes(tc.hex)
actual := string(Decode(code))
assert.Equal(t, actual, expected)
}
}
开发者ID:Jxck,项目名称:hpack,代码行数:8,代码来源:huffman_test.go
示例15: TestEmit
func TestEmit(t *testing.T) {
hl := NewHeaderList()
hf1 := NewHeaderField("key1", "value1")
hf2 := NewHeaderField("key2", "value2")
hl.Emit(hf1)
hl.Emit(hf2)
assert.Equal(t, hl.Len(), 2)
}
开发者ID:Jxck,项目名称:hpack,代码行数:8,代码来源:header_list_test.go
示例16: TestEncodeDecode
func TestEncodeDecode(t *testing.T) {
for _, tc := range testCase {
expected := []byte(tc.str)
encoded := Encode(expected)
actual := Decode(encoded)
assert.Equal(t, actual, expected)
}
}
开发者ID:Jxck,项目名称:hpack,代码行数:8,代码来源:huffman_test.go
示例17: TestPingCase
// PING Frame
func TestPingCase(t *testing.T) {
var c TestCase
var p PingPayload
framecase := []byte(`{
"error": null,
"wire": "0000080600000000006465616462656566",
"frame": {
"length": 8,
"frame_payload": {
"opaque_data": "deadbeef",
"padding_length": null,
"padding": null
},
"flags": 0,
"stream_identifier": 0,
"type": 6
},
"draft": 14,
"description": "noraml ping frame"
}`)
// ignore error
json.Unmarshal(framecase, &c)
json.Unmarshal(c.Frame.Payload, &p)
// trace data
wire := c.Wire
flags := Flag(c.Frame.Flags)
streamId := c.Frame.StreamId
opaqueData := []byte(p.OpaqueData)
// compare struct
expected := NewPingFrame(flags, streamId, opaqueData)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:46,代码来源:frame_test.go
示例18: TestIndexedHeaderEncode
func TestIndexedHeaderEncode(t *testing.T) {
// D.2.3. Indexed Header Field
var index uint32 = 2
buf := []byte{0x82}
frame := NewIndexedHeader(index)
actual := frame.Encode()
assert.Equal(t, actual.Bytes(), buf)
}
开发者ID:Jxck,项目名称:hpack,代码行数:9,代码来源:encoder_test.go
示例19: TestEncode
func TestEncode(t *testing.T) {
for _, tc := range testCase {
raw := []byte(tc.str)
expected := tc.hex
encoded := Encode(raw)
actual := toHexString(encoded)
assert.Equal(t, actual, expected)
}
}
开发者ID:Jxck,项目名称:hpack,代码行数:9,代码来源:huffman_test.go
示例20: TestRstStreamCase
func TestRstStreamCase(t *testing.T) {
var c TestCase
framecase := []byte(`{
"error": null,
"wire": "00000403000000000500000008",
"frame": {
"length": 4,
"frame_payload": {
"error_code": 8,
"padding_length": null,
"padding": null
},
"flags": 0,
"stream_identifier": 5,
"type": 3
},
"draft": 14,
"description": "noraml rst stream frame"
}`)
err := json.Unmarshal(framecase, &c)
if err != nil {
t.Fatal(err)
}
// trace data
wire := c.Wire
streamId := c.Frame.StreamId
// compare struct
expected := NewRstStreamFrame(streamId, 8)
actual, err := ReadFrame(hexToBuffer(wire))
if err != nil {
t.Fatal(err)
}
assert.Equal(t, actual, expected)
// compare wire
buf := bytes.NewBuffer(make([]byte, 0))
expected.Write(buf)
hexdump := strings.ToUpper(hex.EncodeToString(buf.Bytes()))
assert.Equal(t, wire, hexdump)
}
开发者ID:mashuai,项目名称:http2,代码行数:44,代码来源:frame_test.go
注:本文中的github.com/Jxck/assertion.Equal函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论