-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmessage_test.go
73 lines (69 loc) · 1.51 KB
/
message_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
68
69
70
71
72
73
package ipfix
import (
"testing"
"time"
)
func TestMessage_String(t *testing.T) {
helloWorldField := &FixedLengthField{
id: 5,
pen: 12345,
constructor: NewString,
name: "fixedString",
value: &String{
length: 11,
value: "hello world",
},
}
msg := Message{
Version: 10,
Length: 16,
ExportTime: uint32(time.Now().Unix()),
SequenceNumber: 1234,
ObservationDomainId: 0,
Sets: []Set{
{
SetHeader: SetHeader{
Id: 3,
Length: 8,
},
Kind: KindTemplateSet,
Set: &TemplateSet{
Records: []TemplateRecord{
{
FieldCount: 2,
TemplateId: 1000,
Fields: []Field{
helloWorldField,
&VariableLengthField{
id: 6,
name: "stringBasicList",
pen: 12345,
constructor: NewBasicList,
value: &BasicList{
isVariableLength: true,
semantic: SemanticAllOf,
pen: 12345,
fieldId: 5,
isEnterprise: true,
elementLength: VariableLength,
length: 3,
value: []Field{
helloWorldField.Clone().SetValue("hello world 2"),
helloWorldField.Clone().SetValue("hello world 3"),
helloWorldField.Clone().SetValue("hello world 4"),
},
},
},
},
},
},
},
},
},
}
t.Log(msg.String())
err := recover()
if err != nil {
t.Error(err)
}
}