1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-02 19:41:23 +02:00
embd/digitalpin_test.go
Karan Misra 57328c979d gpio: implement pin caching
this allows for the short version of the API to work as expected as
consecutive calls to the same pin would now be internally working on the
pin instance (all the 3 currently supported types). closing a pin busts
the cache
2014-04-06 05:30:54 +05:30

22 lines
539 B
Go

package embd
import "testing"
func TestDigitalPinClose(t *testing.T) {
pinMap := PinMap{
&PinDesc{ID: "P1_1", Aliases: []string{"1"}, Caps: CapDigital},
}
driver := newGPIODriver(pinMap, newDigitalPin, nil, nil)
pin, err := driver.DigitalPin(1)
if err != nil {
t.Fatalf("Looking up digital pin 1: got %v", err)
}
pin.Close()
pin2, err := driver.DigitalPin(1)
if err != nil {
t.Fatalf("Looking up digital pin 1: got %v", err)
}
if pin == pin2 {
t.Fatal("Looking up closed digital pin 1: but got the old instance")
}
}