-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathstatus_test.go
53 lines (48 loc) · 922 Bytes
/
status_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
package acr122u
import (
"bytes"
"testing"
"github.com/ebfe/scard"
)
func TestNewStatus(t *testing.T) {
for _, tc := range []struct {
scs *scard.CardStatus
err error
want Status
}{
{
nil,
scard.ErrUnknownCard,
Status{},
},
{
&scard.CardStatus{
Reader: "Test",
State: scard.Present,
ActiveProtocol: scard.ProtocolAny,
Atr: []byte{0x56, 0x78},
},
nil,
Status{
Reader: "Test",
State: 0x4,
ActiveProtocol: 0x3,
Atr: []byte{0x56, 0x78},
},
},
} {
got, err := newStatus(tc.scs)
if err != tc.err {
t.Fatalf("unexpected error: %v", err)
}
if !got.equal(tc.want) {
t.Fatalf("%#v != %#v", got, tc.want)
}
}
}
func (s Status) equal(o Status) bool {
return s.Reader == o.Reader &&
s.State == o.State &&
s.ActiveProtocol == o.ActiveProtocol &&
bytes.Equal(s.Atr, o.Atr)
}