File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -413,8 +413,8 @@ pub fn (u_ Uint128) str() string {
413413
414414// put_bytes stores u in b in little-endian order
415415pub fn (u Uint128) put_bytes (mut b []u8 ) {
416- binary.little_endian_put_u64 (mut b, u.lo)
417- binary.little_endian_put_u64 (mut b, u.hi)
416+ binary.little_endian_put_u64 (mut b[.. 8 ] , u.lo)
417+ binary.little_endian_put_u64 (mut b[ 8 ..] , u.hi)
418418}
419419
420420// uint128_from_64 converts v to a Uint128 value
Original file line number Diff line number Diff line change 11import math.big
22import math.unsigned
3+ import rand
34
45fn test_str () {
56 x := unsigned.uint128_from_dec_str ('170141183460469231713240559642174554112' ) or { panic ('' ) }
@@ -241,3 +242,13 @@ fn test_div_128() {
241242 }
242243 }
243244}
245+
246+ fn test_put_bytes () {
247+ a := unsigned.uint128_new (rand.u64 (), rand.u64 ())
248+ b := a.reverse_bytes ()
249+ mut buf_a := []u8 {len: 16 }
250+ mut buf_b := []u8 {len: 16 }
251+ a.put_bytes (mut buf_a)
252+ b.put_bytes (mut buf_b)
253+ assert buf_a == buf_b.reverse ()
254+ }
You can’t perform that action at this time.
0 commit comments