From 9a1f97a671d80df29c309b3aae8ad66755bef42f Mon Sep 17 00:00:00 2001 From: xengineering Date: Thu, 30 May 2024 22:53:37 +0200 Subject: software: Refactor unit test for unslip() This allows to easily add test cases. --- software/communication/data_link_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'software') 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); + } } } -- cgit v1.2.3-70-g09d2