File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed
Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -226,5 +226,24 @@ public void WritesStringChunkedOk()
226226
227227 slice . EndRead ( ) ;
228228 }
229+
230+ [ Fact ]
231+ public void StoreSliceStoresBitsAndRefs ( )
232+ {
233+ var original = new CellBuilder ( )
234+ . StoreUInt ( 11 , 32 )
235+ . StoreUInt ( 12 , 32 )
236+ . StoreRef ( new CellBuilder ( ) . StoreBit ( true ) )
237+ . StoreRef ( new CellBuilder ( ) . StoreBit ( false ) )
238+ . Build ( )
239+ . BeginRead ( ) ;
240+
241+ Assert . Equal ( ( uint ) 11 , original . LoadUInt ( 32 ) ) ;
242+ Assert . True ( original . LoadRef ( ) . BeginRead ( ) . LoadBit ( ) ) ;
243+
244+ var slice = new CellBuilder ( ) . StoreSlice ( original ) . Build ( ) . BeginRead ( ) ;
245+ Assert . Equal ( ( uint ) 12 , slice . LoadUInt ( 32 ) ) ;
246+ Assert . False ( slice . LoadRef ( ) . BeginRead ( ) . LoadBit ( ) ) ;
247+ }
229248 }
230249}
Original file line number Diff line number Diff line change @@ -58,9 +58,18 @@ public CellBuilder StoreBits(ReadOnlySpan<bool> values)
5858
5959 public CellBuilder StoreSlice ( Slice value )
6060 {
61- EnsureCanStore ( value . Length ) ;
62- value . LoadBitsTo ( data . AsSpan ( Length , value . Length ) ) ;
63- Length += value . Length ;
61+ var len = value . Length ;
62+ EnsureCanStore ( len ) ;
63+ value . LoadBitsTo ( data . AsSpan ( Length , len ) ) ;
64+ Length += len ;
65+
66+ var rf = value . TryLoadRef ( ) ;
67+ while ( rf != null )
68+ {
69+ StoreRef ( rf ) ;
70+ rf = value . TryLoadRef ( ) ;
71+ }
72+
6473 return this ;
6574 }
6675
You can’t perform that action at this time.
0 commit comments