From 0c386780c188f7b32cd72bb8ce37d5345c4675a8 Mon Sep 17 00:00:00 2001 From: saji Date: Wed, 3 May 2023 14:06:19 -0500 Subject: [PATCH] finish tests, 100% coverage for api_frame --- internal/xbee/api_frame_test.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/internal/xbee/api_frame_test.go b/internal/xbee/api_frame_test.go index 3a453a2..482b47a 100644 --- a/internal/xbee/api_frame_test.go +++ b/internal/xbee/api_frame_test.go @@ -18,7 +18,6 @@ func Test_xbeeFrameSplit(t *testing.T) { wantToken []byte wantErr bool }{ - // TODO: Add test cases. { name: "empty data", args: args{ @@ -127,7 +126,6 @@ func Test_parseFrame(t *testing.T) { want []byte wantErr bool }{ - // TODO: Add test cases. { name: "missing start delimiter", args: args{ @@ -175,10 +173,19 @@ func Test_writeXBeeFrame(t *testing.T) { name string args args wantN int - wantW string + wantW []byte wantErr bool }{ // TODO: Add test cases. + { + name: "a test", + args: args{ + data: []byte{0x23, 0x11}, + }, + wantN: 6, + wantW: []byte{0x7E, 0x00, 0x02, 0x23, 0x11, 0xCB}, + wantErr: false, + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -191,7 +198,7 @@ func Test_writeXBeeFrame(t *testing.T) { if gotN != tt.wantN { t.Errorf("writeXBeeFrame() = %v, want %v", gotN, tt.wantN) } - if gotW := w.String(); gotW != tt.wantW { + if gotW := w.Bytes(); !reflect.DeepEqual(gotW, tt.wantW) { t.Errorf("writeXBeeFrame() = %v, want %v", gotW, tt.wantW) } })