mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-01-29 04:14:51 -05:00
ringbuffer get front/back qtests
This commit is contained in:
parent
ec92dfaa94
commit
356f6934dd
1 changed files with 24 additions and 0 deletions
|
|
@ -577,12 +577,36 @@ struct
|
||||||
else
|
else
|
||||||
get b i
|
get b i
|
||||||
|
|
||||||
|
(*$Q
|
||||||
|
(Q.pair Q.small_int Q.printable_string) (fun (i, s) -> \
|
||||||
|
let s = s ^ " " in \
|
||||||
|
let s_len = Bytes.length s in \
|
||||||
|
let b = ByteBuffer.create s_len in \
|
||||||
|
ByteBuffer.blit_from b s 0 s_len; \
|
||||||
|
let index = abs (i mod ByteBuffer.length b) in \
|
||||||
|
let front = ByteBuffer.get_front b index in \
|
||||||
|
front = Bytes.get s index)
|
||||||
|
*)
|
||||||
|
|
||||||
let get_back b i =
|
let get_back b i =
|
||||||
let offset = ((length b) - i - 1) in
|
let offset = ((length b) - i - 1) in
|
||||||
if offset < 0 then
|
if offset < 0 then
|
||||||
raise (Invalid_argument ("CCRingBuffer.get_back:" ^ string_of_int i))
|
raise (Invalid_argument ("CCRingBuffer.get_back:" ^ string_of_int i))
|
||||||
else get b offset
|
else get b offset
|
||||||
|
|
||||||
|
(*$Q
|
||||||
|
(Q.pair Q.small_int Q.printable_string) (fun (i, s) -> \
|
||||||
|
let s = s ^ " " in \
|
||||||
|
let s_len = Bytes.length s in \
|
||||||
|
let b = ByteBuffer.create s_len in \
|
||||||
|
ByteBuffer.blit_from b s 0 s_len; \
|
||||||
|
let index = abs (i mod ByteBuffer.length b) in \
|
||||||
|
let back = ByteBuffer.get_back b index in \
|
||||||
|
back = Bytes.get s (s_len - index - 1))
|
||||||
|
*)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let to_list b =
|
let to_list b =
|
||||||
let len = length b in
|
let len = length b in
|
||||||
let rec build l i =
|
let rec build l i =
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue