mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
gpio: allow specifying the digital logical pin number as required
This commit is contained in:
parent
83c5f3f4d7
commit
53e6c55378
5 changed files with 153 additions and 108 deletions
29
pin_test.go
Normal file
29
pin_test.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package embd
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestPinMapLookup(t *testing.T) {
|
||||
var tests = []struct {
|
||||
key interface{}
|
||||
id string
|
||||
}{
|
||||
{"10", "P1_1"},
|
||||
{10, "P1_1"},
|
||||
{"P1_2", "P1_2"},
|
||||
{"GPIO10", "P1_2"},
|
||||
}
|
||||
var pinMap = PinMap{
|
||||
&PinDesc{ID: "P1_1", Aliases: []string{"AN1", "10"}},
|
||||
&PinDesc{ID: "P1_2", Aliases: []string{"GPIO10"}},
|
||||
}
|
||||
for _, test := range tests {
|
||||
pd, found := pinMap.Lookup(test.key)
|
||||
if !found {
|
||||
t.Errorf("Could not find a descriptor for %q", test.key)
|
||||
continue
|
||||
}
|
||||
if pd.ID != test.id {
|
||||
t.Errorf("Looking up %q: got %v, want %v", test.key, pd.ID, test.id)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue