-
Notifications
You must be signed in to change notification settings - Fork 110
/
testhelper.go
30 lines (24 loc) · 974 Bytes
/
testhelper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Package testhelper implements a slam service definition with additional exported functions for
// the purpose of testing
package testhelper
import (
"bytes"
"testing"
"github.com/golang/geo/r3"
"go.viam.com/test"
"go.viam.com/rdk/pointcloud"
)
// TestComparePointCloudsFromPCDs is a helper function for checking GetPointCloudMapFull response along with associated pcd validity checks.
func TestComparePointCloudsFromPCDs(t *testing.T, pcdInput, pcdOutput []byte) {
pcInput, err := pointcloud.ReadPCD(bytes.NewReader(pcdInput))
test.That(t, err, test.ShouldBeNil)
pcOutput, err := pointcloud.ReadPCD(bytes.NewReader(pcdOutput))
test.That(t, err, test.ShouldBeNil)
test.That(t, pcInput.MetaData(), test.ShouldResemble, pcOutput.MetaData())
pcInput.Iterate(0, 0, func(p r3.Vector, d pointcloud.Data) bool {
dOutput, ok := pcOutput.At(p.X, p.Y, p.Z)
test.That(t, ok, test.ShouldBeTrue)
test.That(t, dOutput, test.ShouldResemble, d)
return true
})
}