blob: 6be2ba8319f7c4c032c86fd89a3f61ff979b897b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
#lang racket/base
(require rackunit
rackunit/text-ui
(prefix-in layer2- "../ebus/layer2.rkt"))
(define layer2-test
(test-suite
"Tests for Ebus Parser"
(test-case
"Test sample Master-Master Paket"
(let
([paket (layer2-read-ebus
(open-input-bytes
(bytes
170 ; SYN
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? (layer2-ebus-paket-source paket) 003)
(check-eq? (layer2-ebus-paket-destination paket) 241)
(check-eq? (layer2-ebus-paket-primaryCommand paket) 008)
(check-eq? (layer2-ebus-paket-secondaryCommand paket) 000)
(check-eq? (layer2-ebus-paket-payloadLength paket) 008)
(check-eq? (layer2-ebus-paket-payloadLength paket)
(length (layer2-ebus-paket-payload paket)))
))
(test-case
"test invalid paket"
(let
([paket (layer2-read-ebus
(open-input-bytes
(bytes
170 ;SYN
170 ;SYN
016 ;SRC
003 ;DEST
008 ;PRIM => sollwertuebertragungRegler
000 ;SEC => sollwertuebertragungRegler
008 ;PAY
051 ;P1
042 ;P2
000 ;P3
009 ;P4
128 ;P5
019 ;P6
000 ;P7 | ACK
045 ;P8 | ???
170 ;SYN
170 ;SYN
)))])
(check-eq? paket eof)
))
))
(exit (run-tests layer2-test))
|