1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-26 13:48:49 +08:00

Adding basic test coverage to opencv

This commit is contained in:
Javier Cervantes 2014-07-16 16:37:58 -05:00 committed by Adrian Zankich
parent 22839c4d21
commit eee92acd30
4 changed files with 29 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
*.test
*.swp
profile.cov
count.out

View File

@ -6,7 +6,7 @@ import (
)
func initTestCameraDriver() *CameraDriver {
return NewCameraDriver("bot", 0)
return NewCameraDriver("bot", "")
}
func TestCameraDriverStart(t *testing.T) {
@ -15,14 +15,24 @@ func TestCameraDriverStart(t *testing.T) {
gobot.Assert(t, d.Start(), true)
}
func TestCameraDriverStartPanic(t *testing.T) {
recovered := false
defer func() {
if r := recover(); r != nil {
recovered = true
}
}()
NewCameraDriver("bot", false).Start()
gobot.Expect(t, recovered, true)
}
func TestCameraDriverHalt(t *testing.T) {
t.SkipNow()
d := initTestCameraDriver()
gobot.Assert(t, d.Halt(), true)
}
func TestCameraDriverInit(t *testing.T) {
t.SkipNow()
d := initTestCameraDriver()
gobot.Assert(t, d.Init(), true)
}

BIN
platforms/opencv/test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -1,8 +1,11 @@
package opencv
import (
cv "github.com/hybridgroup/go-opencv/opencv"
"github.com/hybridgroup/gobot"
"testing"
"path"
"runtime"
)
func initTestWindowDriver() *WindowDriver {
@ -16,13 +19,21 @@ func TestWindowDriverStart(t *testing.T) {
}
func TestWindowDriverHalt(t *testing.T) {
t.SkipNow()
d := initTestWindowDriver()
gobot.Assert(t, d.Halt(), true)
}
func TestWindowDriverInit(t *testing.T) {
t.SkipNow()
d := initTestWindowDriver()
gobot.Assert(t, d.Init(), true)
}
func TestWindowDriverShowImage(t *testing.T) {
t.SkipNow()
d := initTestWindowDriver()
_, currentfile, _, _ := runtime.Caller(0)
image := cv.LoadImage(path.Join(path.Dir(currentfile), "test.png"))
d.Start()
d.ShowImage(image)
}