Skip to content

Commit

Permalink
upgrade debug parser
Browse files Browse the repository at this point in the history
  • Loading branch information
awalterschulze committed Feb 3, 2025
1 parent 47525ab commit 794a31a
Show file tree
Hide file tree
Showing 10 changed files with 79 additions and 282 deletions.
42 changes: 23 additions & 19 deletions debug/example.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

package debug

import proto "google.golang.org/protobuf/proto"
import (
proto "google.golang.org/protobuf/proto"

"github.com/katydid/parser-go/parser/debug"
)

// Input is a sample instance of the Debug struct.
var Input = &Debug{
Expand All @@ -37,30 +41,30 @@ var Input = &Debug{
}

// Output is a sample instance of Nodes that repesents the Input variable after it has been parsed by Walk.
var Output = Nodes{
Field(`A`, `1`),
Nested(`B`,
Field(`0`, `b2`),
Field(`1`, `b3`),
var Output = debug.Nodes{
debug.Field(`A`, `1`),
debug.Nested(`B`,
debug.Field(`0`, `b2`),
debug.Field(`1`, `b3`),
),
Nested(`C`,
Field(`A`, `2`),
Field(`D`, `3`),
Nested(`E`,
Nested(`0`,
Nested(`B`,
Field(`0`, `b4`),
debug.Nested(`C`,
debug.Field(`A`, `2`),
debug.Field(`D`, `3`),
debug.Nested(`E`,
debug.Nested(`0`,
debug.Nested(`B`,
debug.Field(`0`, `b4`),
),
),
Nested(`1`,
Nested(`B`,
Field(`0`, `b5`),
debug.Nested(`1`,
debug.Nested(`B`,
debug.Field(`0`, `b5`),
),
),
),
),
Field(`D`, `4`),
Nested(`F`,
Field(`0`, `5`),
debug.Field(`D`, `4`),
debug.Nested(`F`,
debug.Field(`0`, `5`),
),
}
36 changes: 0 additions & 36 deletions debug/node.go

This file was deleted.

181 changes: 0 additions & 181 deletions debug/walk.go

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.23
require github.com/awalterschulze/checklicense v1.0.0

require (
github.com/katydid/parser-go v0.6.0
github.com/katydid/parser-go v0.7.0
google.golang.org/protobuf v1.36.3
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/awalterschulze/checklicense v1.0.0 h1:SiRilt26Q+2M238VbXw+e5826mxPypv
github.com/awalterschulze/checklicense v1.0.0/go.mod h1:oUHvoD4crryzAwDwtdQqCnaZRznAvZE64edH9ukb1K4=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/katydid/parser-go v0.6.0 h1:8VFYXEp9pZsq4CCxYLDavPPqOSX+JXsmhjfU4XMB8iw=
github.com/katydid/parser-go v0.6.0/go.mod h1:1BwRfDlyRgDlAaURZ4FXi7IzHqWKTsrCdsstLsFeQho=
github.com/katydid/parser-go v0.7.0 h1:3+z3hWII2oalI8Xpa/+T54q5Tgz6HIX5BQNkdn5Lz9c=
github.com/katydid/parser-go v0.7.0/go.mod h1:1BwRfDlyRgDlAaURZ4FXi7IzHqWKTsrCdsstLsFeQho=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.36.3 h1:82DV7MYdb8anAVi3qge1wSnMDrnKK7ebr+I0hHRN1BU=
Expand Down
6 changes: 3 additions & 3 deletions proto/broken_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ package proto
import (
"testing"

"github.com/katydid/parser-go-proto/debug"
"github.com/katydid/parser-go-proto/proto/prototests"
"github.com/katydid/parser-go/parser/debug"
"google.golang.org/protobuf/proto"
)

Expand All @@ -40,7 +40,7 @@ func TestBrokenLengthValue(t *testing.T) {
t.Fatal(err)
}
// make sure the parser doesn't panic and only returns an error.
if _, err := debug.Walk(protoParser); err == nil {
if _, err := debug.Parse(protoParser); err == nil {
t.Fatal("expected error, because of wrong length")
}
}
Expand All @@ -67,7 +67,7 @@ func TestBrokenLengthMessage(t *testing.T) {
t.Fatal(err)
}
// make sure the parser doesn't panic and only returns an error.
if _, err := debug.Walk(protoParser); err == nil {
if _, err := debug.Parse(protoParser); err == nil {
t.Fatal("expected error, because of wrong length")
}
}
14 changes: 9 additions & 5 deletions proto/packed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import (
"strconv"
"testing"

"github.com/katydid/parser-go-proto/debug"
"github.com/katydid/parser-go-proto/proto/prototests"
"github.com/katydid/parser-go/parser/debug"
"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ func TestPacked1(t *testing.T) {
t.Fatal(err)
}
parser := debug.NewLogger(p, debug.NewLineLogger())
m, err := debug.Walk(parser)
m, err := debug.Parse(parser)
if err != nil {
t.Fatal(err)
}
Expand All @@ -72,7 +72,9 @@ func TestRandomPacked1(t *testing.T) {
t.Fatal(err)
}
l := debug.NewLogger(p, debug.NewLineLogger())
debug.RandomWalk(l, debug.NewRand(), 10, 3)
if err := debug.RandomWalk(l, debug.NewRand(), 10, 3); err != nil {
t.Fatal(err)
}
}
}

Expand Down Expand Up @@ -110,7 +112,7 @@ func TestPacked2(t *testing.T) {
t.Fatal(err)
}
parser := debug.NewLogger(p, debug.NewLineLogger())
m, err := debug.Walk(parser)
m, err := debug.Parse(parser)
if err != nil {
t.Fatal(err)
}
Expand All @@ -133,6 +135,8 @@ func TestRandomPacked2(t *testing.T) {
t.Fatal(err)
}
l := debug.NewLogger(p, debug.NewLineLogger())
debug.RandomWalk(l, debug.NewRand(), 10, 3)
if err := debug.RandomWalk(l, debug.NewRand(), 10, 3); err != nil {
t.Fatal(err)
}
}
}
Loading

0 comments on commit 794a31a

Please sign in to comment.