forked from akares/skreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasurement_spdx_test.go
63 lines (55 loc) · 1.65 KB
/
measurement_spdx_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package skreader_test
import (
"testing"
"time"
"github.com/akares/skreader"
)
func TestMeasurementSPDX(t *testing.T) {
now := time.Now()
for _, tt := range []struct {
name string
measName string
measNote string
testdata []byte
wantRange skreader.ValueRange
wantErr bool
}{
{
name: "range ok",
measName: "test",
measNote: "test",
testdata: skreader.Testdata,
wantRange: skreader.RangeOk,
wantErr: false,
},
{
name: "range under",
measName: "test",
measNote: "test",
testdata: skreader.TestdataUnder,
wantRange: skreader.RangeUnder,
wantErr: false,
},
} {
t.Run(tt.name, func(t *testing.T) {
m, err := skreader.NewMeasurementFromBytes(tt.testdata)
if (err != nil) != tt.wantErr {
t.Errorf("error = %v, wantErr %v", err, tt.wantErr)
}
spdxHeader := skreader.NewSPDXHeader(tt.measName, tt.measNote, now)
if spdxHeader.Comments != tt.measName {
t.Errorf("Comments = %v, want %v", spdxHeader.Comments, tt.measName)
}
if spdxHeader.Description != tt.measName {
t.Errorf("Description = %v, want %v", spdxHeader.Description, tt.measNote)
}
spdxSpectralDistribution := skreader.NewSPDXSpectralDistribution(m)
if spdxSpectralDistribution.SpectralData[0].Value != m.SpectralData1nm[0].Val {
t.Errorf("SpectralData[0].Value = %v, want %v", spdxSpectralDistribution.SpectralData[0].Value, m.SpectralData1nm[0].Val)
}
if spdxSpectralDistribution.SpectralData[400].Value != m.SpectralData1nm[400].Val {
t.Errorf("SpectralData[400].Value = %v, want %v", spdxSpectralDistribution.SpectralData[400].Value, m.SpectralData1nm[400].Val)
}
})
}
}