-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller_test.go
71 lines (67 loc) · 1.35 KB
/
controller_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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Copyright (c) 2020–2024 The prologix developers. All rights reserved.
// Project site: https://github.com/gotmc/prologix
// Use of this source code is governed by a MIT-style license that
// can be found in the LICENSE.txt file for the project.
package prologix
import (
"fmt"
"testing"
)
func TestIsPrimaryAddressValid(t *testing.T) {
tests := []struct {
given int
want bool
}{
{-2, false},
{-1, false},
{0, true},
{1, true},
{15, true},
{30, true},
{31, false},
{96, false},
{126, false},
{131, false},
}
for _, test := range tests {
t.Run(fmt.Sprintf("Test: %d", test.given), func(t *testing.T) {
if got := isPrimaryAddressValid(test.given); got != test.want {
t.Errorf(
"Error getting Date string\n\tgot %v; want %v",
got,
test.want,
)
}
})
}
}
func TestIsSecondaryAddressValid(t *testing.T) {
tests := []struct {
given int
want bool
}{
{-2, false},
{-1, false},
{0, false},
{1, false},
{15, false},
{30, false},
{31, false},
{95, false},
{96, true},
{126, true},
{127, false},
{131, false},
}
for _, test := range tests {
t.Run(fmt.Sprintf("Test: %d", test.given), func(t *testing.T) {
if got := isSecondaryAddressValid(test.given); got != test.want {
t.Errorf(
"Error getting Date string\n\tgot %v; want %v",
got,
test.want,
)
}
})
}
}