forked from brocaar/lorawan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheirp_test.go
51 lines (42 loc) · 807 Bytes
/
eirp_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package lorawan
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
)
func TestGetTXParamSetupEIRPIndex(t *testing.T) {
assert := require.New(t)
tests := []struct {
EIRP float32
ExpectedIndex uint8
}{
{8, 0},
{9, 0},
{10, 1},
{36, 15},
{37, 15},
{12.15, 2},
}
for _, tst := range tests {
assert.Equal(tst.ExpectedIndex, GetTXParamSetupEIRPIndex(tst.EIRP))
}
}
func TestGetTXParamSetupEIRP(t *testing.T) {
assert := require.New(t)
tests := []struct {
Index uint8
EIRP float32
Error error
}{
{0, 8, nil},
{15, 36, nil},
{16, 0, errors.New("lorawan: invalid eirp index")},
}
for _, tst := range tests {
e, err := GetTXParamSetupEIRP(tst.Index)
assert.Equal(tst.Error, err)
if err == nil {
assert.Equal(tst.EIRP, e)
}
}
}