github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/boolprefix/analyzer_test.go (about) 1 package boolprefix 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: "prefix has", 15 Data: ` 16 BO_ 400 MOTOR_STATUS: 3 MOTOR 17 SG_ HasWheelError : 0|1@1+ (1,0) [0|0] "" DRIVER,IO 18 `, 19 }, 20 21 { 22 Name: "prefix is", 23 Data: ` 24 BO_ 400 MOTOR_STATUS: 3 MOTOR 25 SG_ IsOverheated : 0|1@1+ (1,0) [0|0] "" DRIVER,IO 26 `, 27 }, 28 29 { 30 Name: "missing prefix", 31 Data: ` 32 BO_ 400 MOTOR_STATUS: 3 MOTOR 33 SG_ WheelError : 0|1@1+ (1,0) [0|0] "" DRIVER,IO 34 `, 35 Diagnostics: []*analysis.Diagnostic{ 36 { 37 Pos: scanner.Position{Line: 2, Column: 2}, 38 Message: "bool signals (1-bit) must have prefix Is or Has", 39 }, 40 }, 41 }, 42 43 { 44 Name: "missing prefix with value descriptions", 45 Data: ` 46 BO_ 400 MOTOR_STATUS: 3 MOTOR 47 SG_ Status : 0|1@1+ (1,0) [0|0] "" DRIVER,IO 48 49 VAL_ 400 Status 1 "ValidDataPresent" 0 "NoData" ; 50 `, 51 }, 52 }) 53 }