2014-04-06 03:20:09 +02:00
|
|
|
package generic
|
2014-04-06 02:00:54 +02:00
|
|
|
|
2014-04-06 03:20:09 +02:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2016-02-06 07:23:18 +01:00
|
|
|
"github.com/kidoman/embd"
|
2014-04-06 03:20:09 +02:00
|
|
|
)
|
2014-04-06 02:00:54 +02:00
|
|
|
|
|
|
|
func TestDigitalPinClose(t *testing.T) {
|
2014-04-06 03:20:09 +02:00
|
|
|
pinMap := embd.PinMap{
|
|
|
|
&embd.PinDesc{ID: "P1_1", Aliases: []string{"1"}, Caps: embd.CapDigital},
|
2014-04-06 02:00:54 +02:00
|
|
|
}
|
2014-04-06 03:20:09 +02:00
|
|
|
driver := embd.NewGPIODriver(pinMap, NewDigitalPin, nil, nil)
|
2014-04-06 02:00:54 +02:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
}
|