Skip to content

Commit ea1297e

Browse files
committed
add test re: issue 97
1 parent f0e98c4 commit ea1297e

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

ipfix/decoder_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,22 @@ func TestUnknownDatasetsMessage(t *testing.T) {
211211
t.Error("Received unexpected erorr:", err)
212212
}
213213
}
214+
215+
func TestDecodeDataTpl(t *testing.T) {
216+
var payload = []byte{0, 10, 1, 32, 92, 88, 61, 168, 0, 1, 117, 38, 0, 0, 0, 0, 4, 0, 0, 120, 0, 0, 1, 104, 184, 176, 218, 137, 0, 0, 1, 104, 184, 176, 211, 113, 0, 0, 0, 0, 0, 0, 3, 72, 0, 0, 0, 0, 0, 0, 0, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 2, 15, 216, 58, 215, 99, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 104, 184, 176, 218, 137, 0, 0, 1, 104, 184, 176, 211, 113, 0, 0, 0, 0, 0, 0, 3, 72, 0, 0, 0, 0, 0, 0, 0, 10, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 58, 215, 99, 10, 0, 2, 15, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 0, 0, 88, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 0, 0, 0, 0, 0, 189, 0, 0, 0, 0, 0, 0, 0, 1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 254, 128, 0, 0, 0, 0, 0, 0, 31, 12, 114, 32, 178, 94, 204, 189, 255, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 251, 0, 20, 233, 20, 233, 0, 17, 0, 0, 0, 4, 0, 0, 64, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 1, 104, 184, 172, 62, 242, 0, 0, 0, 0, 0, 0, 0, 169, 0, 0, 0, 0, 0, 0, 0, 1, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 0, 2, 15, 224, 0, 0, 251, 20, 233, 20, 233, 0, 0, 17, 0, 0, 0}
217+
var tpl = []byte{0, 10, 1, 32, 92, 88, 61, 152, 0, 1, 117, 22, 0, 0, 0, 0, 0, 2, 0, 68, 4, 0, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 8, 0, 4, 0, 12, 0, 4, 0, 7, 0, 2, 0, 11, 0, 2, 0, 5, 0, 1, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 4, 1, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 8, 0, 4, 0, 12, 0, 4, 0, 7, 0, 2, 0, 11, 0, 2, 0, 5, 0, 1, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 8, 0, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 27, 0, 16, 0, 28, 0, 16, 0, 5, 0, 1, 0, 7, 0, 2, 0, 11, 0, 2, 0, 6, 0, 1, 0, 4, 0, 1, 0, 2, 0, 68, 8, 1, 0, 15, 0, 153, 0, 8, 0, 152, 0, 8, 0, 1, 0, 8, 0, 2, 0, 8, 0, 60, 0, 1, 0, 10, 0, 4, 0, 14, 0, 4, 0, 61, 0, 1, 0, 27, 0, 16, 0, 28, 0, 16, 0, 5, 0, 1, 0, 7, 0, 2, 0, 11, 0, 2, 0, 6, 0, 1, 0, 4, 0, 1}
218+
219+
ip := net.ParseIP("127.0.0.1")
220+
templates := GetCache("")
221+
d := NewDecoder(ip, tpl)
222+
_, err := d.Decode(templates)
223+
if err != nil {
224+
t.Error(err)
225+
}
226+
227+
d = NewDecoder(ip, payload)
228+
_, err = d.Decode(templates)
229+
if err != nil {
230+
t.Error(err)
231+
}
232+
}

0 commit comments

Comments
 (0)