a test
parent
3fb2990284
commit
e763a8cb28
@ -1,4 +1,5 @@
|
||||
#lang restructure/racket
|
||||
|
||||
(r+p "number.rkt"
|
||||
"struct.rkt")
|
||||
"struct.rkt"
|
||||
"decodestream.rkt")
|
@ -0,0 +1,22 @@
|
||||
#lang restructure/racket
|
||||
(require "main.rkt")
|
||||
|
||||
(define Person
|
||||
(make-object RStruct
|
||||
(mhash 'name uint16
|
||||
'age uint8)))
|
||||
|
||||
;; decode a person from a buffer
|
||||
(define stream (open-input-bytes #"ABC"))
|
||||
(define x (send Person decode stream))
|
||||
|
||||
(test-module
|
||||
(check-equal? (hash-ref x 'name) 16961)
|
||||
(check-equal? (hash-ref x 'age) 67))
|
||||
|
||||
;; encode a person from a hash
|
||||
(define out (open-output-bytes))
|
||||
(send Person encode out (hasheq 'name 16961 'age 67))
|
||||
|
||||
(test-module
|
||||
(check-equal? (get-output-bytes out) #"ABC"))
|
Loading…
Reference in New Issue