Ember+ loadable plugin
Source
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
package s101
import (
"testing"
"github.com/google/go-cmp/cmp"
)
func TestEncode(t *testing.T) {
t.Parallel()
type args struct {
message []byte
packetType uint8
}
tests := []struct {
name string
args args
want []uint8
}{
{
"+valid",
args{
[]byte{
0x60, 0x80, 0x6b, 0x80, 0xa0, 0x80, 0x62, 0x80, 0xa0, 0x03, 0x02, 0x01, 0x20, 0xa1, 0x03, 0x02,
0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
0x60,
},
[]byte{
0xfe, 0x00, 0x0e, 0x00, 0x01, 0x60, 0x01, 0x02, 0x28, 0x02, 0x60, 0x80, 0x6b, 0x80, 0xa0, 0x80, 0x62,
0x80, 0xa0, 0x03, 0x02, 0x01, 0x20, 0xa1, 0x03, 0x02, 0x01, 0xfd, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x09, 0x0d, 0xff,
},
},
{
"+multiPacket",
args{
[]byte{
0x60, 0x80, 0x6b, 0x80, 0xa0, 0x80, 0x62, 0x80, 0xa0, 0x03, 0x02, 0x01, 0x20, 0xa1, 0x03, 0x02,
0x01, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
},
0x80,
},
[]byte{
0xfe, 0x00, 0x0e, 0x00, 0x01, 0x80, 0x01, 0x02, 0x28, 0x02, 0x60, 0x80, 0x6b, 0x80, 0xa0, 0x80, 0x62,
0x80, 0xa0, 0x03, 0x02, 0x01, 0x20, 0xa1, 0x03, 0x02, 0x01, 0xfd, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x50, 0x30, 0xff, 0xfe, 0x00, 0x0e, 0x00, 0x01, 0x40, 0x01, 0x02, 0x28, 0x02, 0x01,