mirror of
https://github.com/kidoman/embd
synced 2025-07-02 19:41:23 +02:00

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
22 lines
539 B
Go
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")
|
|
}
|
|
}
|