Skip to content

Commit

Permalink
Merge pull request #3 from go-gnss/fix-int-parsing
Browse files Browse the repository at this point in the history
Update restruct dependency and add ECEF check test
  • Loading branch information
umeat authored May 25, 2021
2 parents 2915443 + 89ca994 commit 9da6065
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.14
require (
github.com/bamiaux/iobit v0.0.0-20170418073505-498159a04883
github.com/go-gnss/ntrip v0.0.0-20200406053254-a4467bfee793
github.com/go-restruct/restruct v0.0.0-20190418070341-acd4e4c2cb35
github.com/go-restruct/restruct v1.2.0-alpha.0.20210525045353-983b86fa188e
github.com/google/go-cmp v0.3.1
github.com/pkg/errors v0.9.1 // indirect
github.com/stretchr/testify v1.5.1 // indirect
Expand Down
8 changes: 6 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ github.com/go-gnss/ntrip v0.0.0-20200406053254-a4467bfee793/go.mod h1:2WGh2w0xlc
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-restruct/restruct v0.0.0-20190418070341-acd4e4c2cb35 h1:j25NJ/ok0rD2O/TX/x+XSYkY+iLFGuEydp5SNHtulyQ=
github.com/go-restruct/restruct v0.0.0-20190418070341-acd4e4c2cb35/go.mod h1:e2k/t2/850rC773ilFYQSoqyJ78SpTx7gtFtOY6/AYA=
github.com/go-restruct/restruct v1.2.0-alpha h1:2Lp474S/9660+SJjpVxoKuWX09JsXHSrdV7Nv3/gkvc=
github.com/go-restruct/restruct v1.2.0-alpha/go.mod h1:KqrpKpn4M8OLznErihXTGLlsXFGeLxHUrLRRI/1YjGk=
github.com/go-restruct/restruct v1.2.0-alpha.0.20210525045353-983b86fa188e h1:PIFVUcdZ9OADg9XAsN0I8OzUzmYXHU+2msP2X7ST/fo=
github.com/go-restruct/restruct v1.2.0-alpha.0.20210525045353-983b86fa188e/go.mod h1:KqrpKpn4M8OLznErihXTGLlsXFGeLxHUrLRRI/1YjGk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
Expand Down Expand Up @@ -81,6 +83,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down Expand Up @@ -108,6 +111,7 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
Expand Down
25 changes: 23 additions & 2 deletions rtcm3/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package rtcm3_test
import (
"bufio"
"fmt"
"github.com/go-gnss/rtcm/rtcm3"
"github.com/google/go-cmp/cmp"
"os"
"testing"

"github.com/go-gnss/rtcm/rtcm3"
"github.com/google/go-cmp/cmp"
)

var (
Expand All @@ -28,6 +29,26 @@ func readPayload(msgNumber uint) (payload []byte) {
return frame.Payload
}

func TestCoords(t *testing.T) {
var x int64 = -44723575368
var y int64 = 26704851794
var z int64 = -36693744263

binary := readPayload(1006)
msg := rtcm3.DeserializeMessage(binary)
c := msg.(rtcm3.Message1006)

if c.ReferencePointX != x {
t.Errorf("parsed 1006 ECEF X coord incorrectly: expected %q received %q", x, c.ReferencePointX)
}
if c.ReferencePointY != y {
t.Errorf("parsed 1006 ECEF Y coord incorrectly: expected %q received %q", y, c.ReferencePointX)
}
if c.ReferencePointZ != z {
t.Errorf("parsed 1006 ECEF Z coord incorrectly: expected %q received %q", z, c.ReferencePointX)
}
}

func TestSerializeDeserialize(t *testing.T) {
for _, number := range messages {
binary := readPayload(uint(number))
Expand Down

0 comments on commit 9da6065

Please sign in to comment.