@@ -9,23 +9,43 @@ import (
99func TestParseXAttrIndex (t * testing.T ) {
1010 tests := []struct {
1111 b []byte
12+ o map [uint32 ]uint32
1213 x * xAttrIndex
1314 err error
1415 }{
15- {[]byte {0x0 , 0x1 }, nil , fmt .Errorf ("cannot parse xAttr Index of size %d less than minimum %d" , 2 , xAttrIDEntrySize )},
16+ {[]byte {0x0 , 0x1 }, map [ uint32 ] uint32 { 0 : 0 }, nil , fmt .Errorf ("cannot parse xAttr Index of size %d less than minimum %d" , 2 , xAttrIDEntrySize )},
1617 {[]byte {
17- 0x0 , 0x1 , 0x2 , 0x3 , 0x4 , 0x5 , 0x6 , 0x7 ,
18- 0x8 , 0x9 , 0xa , 0xb ,
19- 0xc , 0xd , 0xe , 0xf ,
20- 0x10 , 0x11 , 0x12 , 0x13 , 0x14 },
18+ 0x0 , 0x1 , // position in decompressed
19+ 0x2 , 0x3 , 0x4 , 0x5 , // offset of compressed data
20+ 0x6 , 0x7 , 0x8 , 0x9 , 0xa , 0xb , 0xc , 0xd ,
21+ 0xe , 0xf , 0x10 , 0x11 , 0x12 , 0x13 , 0x14 },
22+ map [uint32 ]uint32 {},
23+ nil , fmt .Errorf ("cannot parse xAttr Index invalid offset key %d" , 84148994 )},
24+ {[]byte {
25+ 0x0 , 0x1 , // position in decompressed
26+ 0x2 , 0x3 , 0x4 , 0x5 , // offset of compressed data
27+ 0x6 , 0x7 , 0x8 , 0x9 , 0xa , 0xb , 0xc , 0xd ,
28+ 0xe , 0xf , 0x10 , 0x11 , 0x12 , 0x13 , 0x14 },
29+ map [uint32 ]uint32 {84148994 : 5 },
30+ & xAttrIndex {
31+ pos : 261 ,
32+ count : 0x0b0a0908 ,
33+ size : 0x0f0e0d0c ,
34+ }, nil },
35+ {[]byte {
36+ 0x0 , 0x1 , // position in decompressed
37+ 0x2 , 0x0 , 0x0 , 0x0 , // offset of compressed data
38+ 0x6 , 0x7 , 0x8 , 0x9 , 0xa , 0xb , 0xc , 0xd ,
39+ 0xe , 0xf , 0x10 , 0x11 , 0x12 , 0x13 , 0x14 },
40+ map [uint32 ]uint32 {2 : 0 },
2141 & xAttrIndex {
22- pos : 0x0706050403020100 ,
42+ pos : 256 ,
2343 count : 0x0b0a0908 ,
2444 size : 0x0f0e0d0c ,
2545 }, nil },
2646 }
2747 for i , tt := range tests {
28- x , err := parseXAttrIndex (tt .b )
48+ x , err := parseXAttrIndex (tt .b , tt . o )
2949 switch {
3050 case (err == nil && tt .err != nil ) || (err != nil && tt .err == nil ) || (err != nil && tt .err != nil && ! strings .HasPrefix (err .Error (), tt .err .Error ())):
3151 t .Errorf ("%d: mismatched error, actual then expected" , i )
0 commit comments