diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2012-02-26 18:34:22 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2012-02-26 18:34:22 +0100 |
commit | e01f36c90c19ddf52c4c3b2f9d14f1fb52349c4a (patch) | |
tree | 94d26be665c5812766ba36f7faaa50bb0a4f2b93 /ebus-racket/parser-test.rkt | |
parent | e29ae1a6042978ed2e231889b0cd52b6d8e5155e (diff) | |
download | ebus-alt-e01f36c90c19ddf52c4c3b2f9d14f1fb52349c4a.tar.gz ebus-alt-e01f36c90c19ddf52c4c3b2f9d14f1fb52349c4a.zip |
ebus-racket: simple unittest
Diffstat (limited to 'ebus-racket/parser-test.rkt')
-rw-r--r-- | ebus-racket/parser-test.rkt | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/ebus-racket/parser-test.rkt b/ebus-racket/parser-test.rkt new file mode 100644 index 0000000..672dff2 --- /dev/null +++ b/ebus-racket/parser-test.rkt @@ -0,0 +1,56 @@ +#lang racket +(require rackunit + rackunit/text-ui + (prefix-in parser: "parser.rkt")) + +(define parser-test + (test-suite + "Tests for Ebus Parser" + (test-case + "Test sample Master-Master Paket" + (let + ([paket (parser:read-ebus (open-input-bytes (bytes + 170 ; SYN + 170 + 170 + 003 ; Source + 241 ; Destination + 008 ; primaryCommand + 000 ; secondaryCommand + 008 ; payloadLength + 128 ; p1 + 040 ; p2 + 230 ; p3 + 002 ; p4 + 000 ; p5 + 002 ; p6 + 000 ; p7 + 010 ; p8 + 128 ; CRC + 000 ; ACK + 170 ; SYN + 170)))]) + (check-eq? (parser:ebus-header-source (parser:ebus-paket-header paket)) 003) + (check-eq? (parser:ebus-header-destination (parser:ebus-paket-header paket)) 241) + (check-eq? (parser:ebus-header-primaryCommand (parser:ebus-paket-header paket)) 008) + (check-eq? (parser:ebus-header-secondaryCommand (parser:ebus-paket-header paket)) 000) + (check-eq? (parser:ebus-header-payloadLength (parser:ebus-paket-header paket)) 008) + (check-eq? (parser:ebus-header-payloadLength (parser:ebus-paket-header paket)) + (length (parser:ebus-paket-payload paket))) + )))) + +;(check-equal? (my-+ 1 1) 2 "Simple addition") + + ;(check-equal? (my-* 1 2) 2 "Simple multiplication") +; +; (test-case +; "List has length 4 and all elements even" +; (let ([lst (list 2 4 6 9)]) +; (check = (length lst) 4) +; (for-each +; (lambda (elt) +; (check-pred even? elt)) +; lst))))) + + +(run-tests parser-test)
\ No newline at end of file |