summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-05-30 22:53:37 +0200
committerxengineering <me@xengineering.eu>2024-05-30 22:53:58 +0200
commit9a1f97a671d80df29c309b3aae8ad66755bef42f (patch)
treee9b53612158d685d1b1188a2c0860c00de42b984
parentb1206aaa1f6bc4a04509149024402dea9da12e27 (diff)
downloadiot-core-9a1f97a671d80df29c309b3aae8ad66755bef42f.tar
iot-core-9a1f97a671d80df29c309b3aae8ad66755bef42f.tar.zst
iot-core-9a1f97a671d80df29c309b3aae8ad66755bef42f.zip
software: Refactor unit test for unslip()
This allows to easily add test cases.
-rw-r--r--software/communication/data_link_test.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/software/communication/data_link_test.go b/software/communication/data_link_test.go
index 91b941d..ce8fe10 100644
--- a/software/communication/data_link_test.go
+++ b/software/communication/data_link_test.go
@@ -10,6 +10,10 @@ func TestUnslip(t *testing.T) {
0xFF, 0x12, SLIP_END,
}
+ output := [][]byte{
+ {0xFF, 0x12},
+ }
+
bytes := make(chan byte)
frames := make(chan []byte)
@@ -25,9 +29,10 @@ func TestUnslip(t *testing.T) {
}
}()
- frame := <-frames
- expected := []byte{0xFF, 0x12}
- if !reflect.DeepEqual(frame, expected) {
- t.Fatalf("Frame '%v' does not match expected '%v'\n", frame, expected)
+ for _, v := range output {
+ frame := <-frames
+ if !reflect.DeepEqual(frame, v) {
+ t.Fatalf("Frame '%v' does not match expected '%v'\n", frame, v);
+ }
}
}