You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/restructure/test.rkt

22 lines
531 B
Racket

8 years ago
#lang restructure/racket
(require "main.rkt")
(define Person
(make-object RStruct
(mhash 'name uint16
'age uint8)))
;; decode a person from a buffer
8 years ago
(define stream (make-object RDecodeStream #"ABC"))
8 years ago
(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
8 years ago
(define out (make-object REncodeStream))
8 years ago
(send Person encode out (hasheq 'name 16961 'age 67))
(test-module
8 years ago
(check-equal? (send out dump) #"ABC"))