update tracing test

This commit is contained in:
Simon Cruanes 2022-09-26 20:47:48 -04:00
parent 45eebaae0f
commit 17ac25d314
No known key found for this signature in database
GPG key ID: EBFFF6F283F3A2B4
2 changed files with 13 additions and 2 deletions

View file

@ -4,6 +4,10 @@ li50e2:Tcd3:tag5:c.str2:tyi13e1:v1:aee
li89e2:Tpl0:i13ei13eee li89e2:Tpl0:i13ei13eee
li112e2:Tcd3:tag5:c.str2:tyi89e1:v1:pee li112e2:Tcd3:tag5:c.str2:tyi89e1:v1:pee
li152e2:T@li112ei50eee li152e2:T@li112ei50eee
li175e2:Tcd3:tag5:c.str2:tyi13e1:v1:bee
li215e2:Tcd3:tag5:c.str2:tyi89e1:v1:qee
li255e2:T@li215ei175eee
(len 175) (len 279)
read pa: (p a) read pa: (p a)
read qb: (q b)

View file

@ -28,9 +28,11 @@ end
let buf = Buffer.create 32 let buf = Buffer.create 32
let tracer = Tracer.create ~sink:(Sink.of_buffer_using_bencode buf) () let tracer = Tracer.create ~sink:(Sink.of_buffer_using_bencode buf) ()
let id_pa = Tracer.emit tracer pa let id_pa = Tracer.emit tracer pa
let id_pa' = Tracer.emit tracer pa;; let id_pa' = Tracer.emit tracer pa
let id_qb = Tracer.emit tracer qb;;
assert (Entry_id.equal id_pa id_pa');; assert (Entry_id.equal id_pa id_pa');;
assert (not @@ Entry_id.equal id_pa id_qb);;
Printf.printf "buf containing pa: %s\n(len %d)\n%!" (Buffer.contents buf) Printf.printf "buf containing pa: %s\n(len %d)\n%!" (Buffer.contents buf)
(String.length @@ Buffer.contents buf) (String.length @@ Buffer.contents buf)
@ -47,3 +49,8 @@ let () =
match Trace_reader.read_term trace_reader id_pa with match Trace_reader.read_term trace_reader id_pa with
| Ok t -> Fmt.printf "read pa: %a@." Term.pp t | Ok t -> Fmt.printf "read pa: %a@." Term.pp t
| Error e -> Fmt.printf "could not read pa: %s" e | Error e -> Fmt.printf "could not read pa: %s" e
let () =
match Trace_reader.read_term trace_reader id_qb with
| Ok t -> Fmt.printf "read qb: %a@." Term.pp t
| Error e -> Fmt.printf "could not read qb: %s" e