@@ -2,6 +2,7 @@ package idxfile_test
22
33import (
44 "bytes"
5+ "encoding/base64"
56 "fmt"
67 "testing"
78
@@ -65,3 +66,76 @@ func (s *IdxfileSuite) TestDecodeCRCs(c *C) {
6566
6667 c .Assert (idx .Entries , DeepEquals , i .Entries )
6768}
69+
70+ func (s * IdxfileSuite ) TestDecode64bitsOffsets (c * C ) {
71+ f := bytes .NewBufferString (fixtureLarge4GB )
72+
73+ idx := & Idxfile {}
74+
75+ d := NewDecoder (base64 .NewDecoder (base64 .StdEncoding , f ))
76+ err := d .Decode (idx )
77+ c .Assert (err , IsNil )
78+
79+ expected := map [string ]uint64 {
80+ "303953e5aa461c203a324821bc1717f9b4fff895" : 12 ,
81+ "5296768e3d9f661387ccbff18c4dea6c997fd78c" : 142 ,
82+ "03fc8d58d44267274edef4585eaeeb445879d33f" : 1601322837 ,
83+ "8f3ceb4ea4cb9e4a0f751795eb41c9a4f07be772" : 2646996529 ,
84+ "e0d1d625010087f79c9e01ad9d8f95e1628dda02" : 3452385606 ,
85+ "90eba326cdc4d1d61c5ad25224ccbf08731dd041" : 3707047470 ,
86+ "bab53055add7bc35882758a922c54a874d6b1272" : 5323223332 ,
87+ "1b8995f51987d8a449ca5ea4356595102dc2fbd4" : 5894072943 ,
88+ "35858be9c6f5914cbe6768489c41eb6809a2bceb" : 5924278919 ,
89+ }
90+
91+ for _ , e := range idx .Entries {
92+ c .Assert (expected [e .Hash .String ()], Equals , e .Offset )
93+ }
94+ }
95+
96+ func (s * IdxfileSuite ) TestDecode64bitsOffsetsIdempotent (c * C ) {
97+ f := bytes .NewBufferString (fixtureLarge4GB )
98+
99+ expected := & Idxfile {}
100+
101+ d := NewDecoder (base64 .NewDecoder (base64 .StdEncoding , f ))
102+ err := d .Decode (expected )
103+ c .Assert (err , IsNil )
104+
105+ buf := bytes .NewBuffer (nil )
106+ _ , err = NewEncoder (buf ).Encode (expected )
107+ c .Assert (err , IsNil )
108+
109+ idx := & Idxfile {}
110+ err = NewDecoder (buf ).Decode (idx )
111+ c .Assert (err , IsNil )
112+
113+ c .Assert (idx .Entries , DeepEquals , expected .Entries )
114+ }
115+
116+ const fixtureLarge4GB = `/3RPYwAAAAIAAAAAAAAAAAAAAAAAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEA
117+ AAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAA
118+ AAEAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAACAAAA
119+ AgAAAAIAAAACAAAAAgAAAAIAAAACAAAAAgAAAAIAAAADAAAAAwAAAAMAAAADAAAAAwAAAAQAAAAE
120+ AAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQA
121+ AAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABAAAAAQAAAAEAAAABQAA
122+ AAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAA
123+ BQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAF
124+ AAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUA
125+ AAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAAAAUAAAAFAAAABQAA
126+ AAUAAAAFAAAABQAAAAYAAAAHAAAABwAAAAcAAAAHAAAABwAAAAcAAAAHAAAABwAAAAcAAAAHAAAA
127+ BwAAAAcAAAAHAAAABwAAAAcAAAAHAAAABwAAAAcAAAAHAAAABwAAAAcAAAAHAAAABwAAAAcAAAAH
128+ AAAABwAAAAcAAAAHAAAABwAAAAcAAAA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