~williewillus/racket-rfc8949

8261d9fefdf856b03fcbf4f6adc60d1a6a89b4fc — Vincent Lee 3 years ago 662aca9
Test vector and sequence encoding
1 files changed, 13 insertions(+), 1 deletions(-)

M encode.rkt
M encode.rkt => encode.rkt +13 -1
@@ 140,6 140,7 @@
(module* test #f
  (require rackunit
           "decode.rkt"
           "private/util.rkt"
           "private/test_data.rkt")

  (define (try v)


@@ 166,7 167,18 @@
    (for ([pair (in-list list-examples)])
      (let ([v (car pair)]
            [expected (cdr pair)])
        (check-equal? (try v) expected))))
        (check-equal? (try v) expected)
        (check-equal? (try (list->vector v)) expected)))
    ; indefinite length (sequences)
    (check-equal? (try (in-list '())) (hex-bytes "9fff"))
    (check-equal? (try (in-list (list 1 '(2 3) (in-list '(4 5)))))
                  (hex-bytes "9f018202039f0405ffff"))
    (check-equal? (try (in-list '(1 (2 3) (4 5))))
                  (hex-bytes "9f01820203820405ff"))
    (check-equal? (try (list 1 '(2 3) (in-list '(4 5))))
                  (hex-bytes "83018202039f0405ff"))
    (check-equal? (try (list 1 (in-list '(2 3)) '(4 5)))
                  (hex-bytes "83019f0203ff820405")))

  (test-case
      "Serialization - RFC 8949 Map and Mixed Map/List Examples"