github.com/blueinnovationsgroup/can-go@v0.0.0-20230518195432-d0567cda0028/pkg/dbc/analysis/passes/siunits/analyzer_test.go (about)

     1  package siunits
     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  BO_ 400 TestMessage: 3 ECU1
    17   SG_ SpeedMps : 0|1@1+ (1,0) [0|0] "m/s" DRIVER,IO
    18  `,
    19  		},
    20  
    21  		{
    22  			Name: "not ok",
    23  			Data: `
    24  BO_ 400 TestMessage: 3 ECU1
    25   SG_ SpeedMps : 0|1@1+ (1,0) [0|0] "meters/sec" DRIVER,IO
    26  `,
    27  			Diagnostics: []*analysis.Diagnostic{
    28  				{
    29  					Pos:     scanner.Position{Line: 2, Column: 2},
    30  					Message: "signal with unit meters/sec should have SI unit m/s",
    31  				},
    32  			},
    33  		},
    34  	})
    35  }