Skip to content

Commit

Permalink
removed some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FerroO2000 committed Apr 16, 2024
1 parent f146425 commit 2f9d088
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 47 deletions.
19 changes: 6 additions & 13 deletions adapters_test.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package acmelib

import (
"os"
"testing"
// func Test_LoadDBC(t *testing.T) {
// assert := assert.New(t)

"github.com/stretchr/testify/assert"
)
// net, err := LoadDBC("test_network", "./testdata/mcb.dbc")
// assert.NoError(err)

func Test_LoadDBC(t *testing.T) {
assert := assert.New(t)

net, err := LoadDBC("test_network", "./testdata/mcb.dbc")
assert.NoError(err)

assert.NoError(os.WriteFile("./testdata_res/mcb.txt", []byte(net.String()), 0644))
}
// assert.NoError(os.WriteFile("./testdata_res/mcb.txt", []byte(net.String()), 0644))
// }
10 changes: 2 additions & 8 deletions dbc/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ func GetNewSymbols() []string {
return newSymbolsValues
}

// LocationPos specifies the line and the column in the file.
type LocationPos struct {
Line int
Col int
}

// Location is the position in the DBC file of an AST entity.
type Location struct {
Filename string
StartPos *LocationPos
EndPos *LocationPos
Line int
Col int
}

// File definition:
Expand Down
30 changes: 4 additions & 26 deletions dbc/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ type Parser struct {
usePrev bool
currToken *token

filename string
locPosStack []*LocationPos
filename string

foundVer bool
foundNewSym bool
Expand All @@ -31,8 +30,7 @@ func NewParser(filename string, file []byte) *Parser {

usePrev: false,

filename: filename,
locPosStack: []*LocationPos{},
filename: filename,

foundVer: false,
foundNewSym: false,
Expand Down Expand Up @@ -91,30 +89,11 @@ func (p *Parser) unscan() {
p.usePrev = true
}

func (p *Parser) pushLocationPos() {
p.locPosStack = append(p.locPosStack, &LocationPos{
Line: p.currToken.line,
Col: p.currToken.col,
})
}

func (p *Parser) popLocationPos() *LocationPos {
if len(p.locPosStack) == 0 {
return nil
}
pos := p.locPosStack[len(p.locPosStack)-1]
p.locPosStack = p.locPosStack[:len(p.locPosStack)-1]
return pos
}

func (p *Parser) getLocation() *Location {
return &Location{
Filename: p.filename,
StartPos: p.popLocationPos(),
EndPos: &LocationPos{
Line: p.currToken.line,
Col: p.currToken.col,
},
Line: p.currToken.line,
Col: p.currToken.col,
}
}

Expand Down Expand Up @@ -143,7 +122,6 @@ func (p *Parser) Parse() (*File, error) {
}

t := p.scan()

for !t.isEOF() {
switch t.kind {
case tokenError:
Expand Down

0 comments on commit 2f9d088

Please sign in to comment.