Ember+ loadable plugin
Source
xxxxxxxxxx
/*
** 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 asn1
import (
"bytes"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestNewDecoder(t *testing.T) {
t.Parallel()
type args struct {
b []byte
}
tests := []struct {
name string
args args
want *Decoder
}{
{
"+valid",
args{
[]byte{0x00, 0x01, 0x02},
},
&Decoder{bytes.NewBuffer([]byte{0x00, 0x01, 0x02})},
},
{
"+empty",
args{
[]byte{},
},
&Decoder{bytes.NewBuffer([]byte{})},
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := NewDecoder(tt.args.b)
if diff := cmp.Diff(tt.want.data, got.data, cmp.AllowUnexported(bytes.Buffer{})); diff != "" {
t.Fatalf("NewDecoder() = %s", diff)
}
})
}
}
func TestDecoder_Bytes(t *testing.T) {
t.Parallel()
type fields struct {
data *bytes.Buffer
}
tests := []struct {
name string
fields fields
want []byte
}{
{
"+valid",
fields{
bytes.NewBuffer([]byte{0x00, 0x01, 0x02}),
},
[]byte{0x00, 0x01, 0x02},
},
{
"+empty",
fields{
bytes.NewBuffer([]byte{}),
},
[]byte{},
},
{