Skip to content
This repository was archived by the owner on May 31, 2020. It is now read-only.

Commit 7ff35ff

Browse files
committed
Add test
Signed-off-by: Lehner Florian <[email protected]>
1 parent 9b96461 commit 7ff35ff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

datatypes_test.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ func TestExtractDataElement(t *testing.T) {
197197
ele interface{}
198198
err string
199199
}{
200-
{name: "Unknown", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: 42, numberOfBytes: 42, step: 0, err: "unexpected EOF"},
200+
{name: "TooLessData", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: 42, numberOfBytes: 42, step: 0, err: "unexpected EOF"},
201+
{name: "Unknown", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: 42, numberOfBytes: 4, step: 0, err: "is not supported"},
201202
{name: "MiInt8", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: MiInt8, numberOfBytes: 1, step: 1, ele: []interface{}{17}},
202203
{name: "MiUint8", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: MiUint8, numberOfBytes: 1, step: 1, ele: 17},
203204
{name: "MiInt16", data: []byte{0x11, 0x22, 0x33, 0x44}, order: binary.LittleEndian, dataType: MiInt16, numberOfBytes: 2, step: 2, ele: 8721},
@@ -290,6 +291,8 @@ func TestExtractFieldNames(t *testing.T) {
290291
err string
291292
}{
292293
{name: "['abc']", data: []byte{0x61, 0x62, 0x63}, fieldNameLength: 3, numberOfFields: 1, fields: []string{"abc"}},
294+
{name: "0", data: []byte{0x00}, fieldNameLength: 0, numberOfFields: 0},
295+
{name: "UnableToRead", data: []byte{0x61, 0x62, 0x63}, fieldNameLength: 9, numberOfFields: 1, err: "unexpected EOF"},
293296
}
294297

295298
for _, tc := range tests {
@@ -327,6 +330,7 @@ func TestExtractArrayName(t *testing.T) {
327330
{name: "ThisIsALongerName", data: []byte{0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x54, 0x68, 0x69, 0x73, 0x49, 0x73, 0x41, 0x4c, 0x6f, 0x6e, 0x67, 0x65, 0x72, 0x4e, 0x61, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, order: binary.LittleEndian, step: 25, arrayName: "ThisIsALongerName"},
328331
{name: "TooFewBytes", data: []byte{0x01, 0x10}, order: binary.LittleEndian, step: 1, err: "Unable to read"},
329332
{name: "ZeroLength", data: []byte{0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, order: binary.LittleEndian, step: 8, arrayName: ""},
333+
{name: "UnableToRead", data: []byte{0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00}, order: binary.LittleEndian, err: "Unable to read"},
330334
}
331335

332336
for _, tc := range tests {

matf_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func TestExtractMatrix(t *testing.T) {
240240
}{
241241
{name: "notExpectedArrayFlagSize", data: []byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, err: "will not read 0 bytes"},
242242
{name: "invalidSmallTag", data: []byte{0x00, 0x01, 0x02, 0x03}, err: "EOF"},
243+
{name: "tooFewBytes", data: []byte{0x00, 0x01}, err: "EOF"},
243244
}
244245

245246
for _, tc := range tests {

0 commit comments

Comments
 (0)