blob: ce8fe10d7d56fc91238e0f9bac8d079cda63a573 (
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
|
package communication
import (
"reflect"
"testing"
)
func TestUnslip(t *testing.T) {
input := []byte{
0xFF, 0x12, SLIP_END,
}
output := [][]byte{
{0xFF, 0x12},
}
bytes := make(chan byte)
frames := make(chan []byte)
go func() {
for _, v := range input {
bytes <- v
}
}()
go func() {
for {
frames <- unslip(bytes)
}
}()
for _, v := range output {
frame := <-frames
if !reflect.DeepEqual(frame, v) {
t.Fatalf("Frame '%v' does not match expected '%v'\n", frame, v);
}
}
}
|