github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/singletondefinitions/analyzer_test.go (about) 1 package singletondefinitions 2 3 import ( 4 "testing" 5 "text/scanner" 6 7 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis" 8 "github.com/blueinnovationsgroup/can-go/pkg/dbc/analysis/analysistest" 9 ) 10 11 func TestAnalyzer(t *testing.T) { 12 analysistest.Run(t, Analyzer(), []*analysistest.Case{ 13 { 14 Name: "ok", 15 Data: ` 16 VERSION "foo" 17 NS_: 18 BS_: 19 BU_: ECU1 20 `, 21 }, 22 23 { 24 Name: "multiple versions", 25 Data: ` 26 VERSION "foo" 27 VERSION "foo" 28 NS_: 29 BS_: 30 BU_: ECU1 31 `, 32 Diagnostics: []*analysis.Diagnostic{ 33 { 34 Pos: scanner.Position{Line: 2, Column: 1}, 35 Message: "more than one definition not allowed", 36 }, 37 }, 38 }, 39 40 { 41 Name: "multiple new symbols", 42 Data: ` 43 VERSION "foo" 44 NS_: 45 NS_: 46 BS_: 47 BU_: ECU1 48 `, 49 Diagnostics: []*analysis.Diagnostic{ 50 { 51 Pos: scanner.Position{Line: 3, Column: 1}, 52 Message: "more than one definition not allowed", 53 }, 54 }, 55 }, 56 57 { 58 Name: "multiple bit timing", 59 Data: ` 60 VERSION "foo" 61 NS_: 62 BS_: 63 BS_: 64 BU_: ECU1 65 `, 66 Diagnostics: []*analysis.Diagnostic{ 67 { 68 Pos: scanner.Position{Line: 4, Column: 1}, 69 Message: "more than one definition not allowed", 70 }, 71 }, 72 }, 73 74 { 75 Name: "multiple nodes", 76 Data: ` 77 VERSION "foo" 78 NS_: 79 BS_: 80 BU_: ECU1 81 BU_: ECU2 82 `, 83 Diagnostics: []*analysis.Diagnostic{ 84 { 85 Pos: scanner.Position{Line: 5, Column: 1}, 86 Message: "more than one definition not allowed", 87 }, 88 }, 89 }, 90 }) 91 }