Skip to content

Commit a51105f

Browse files
committed
fix checksum validation in parseStandardDataset
1 parent 118b0c9 commit a51105f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

parser_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,22 @@ func TestParseHistoricDataset(t *testing.T) {
5454
}
5555

5656
func TestParseStandardDataset(t *testing.T) {
57-
frame := "OPTARIF\tBASE\t0"
57+
frame := "ADCO\t021528603314\t#"
5858
dataset, err := parseStandardDataset(frame)
5959
if err != nil {
6060
t.Errorf("Unexpected error: %s", err)
6161
}
6262

63-
if dataset.Label != "OPTARIF" {
64-
t.Errorf("Expected label OPTARIF, got %s", dataset.Label)
63+
if dataset.Label != "ADCO" {
64+
t.Errorf("Expected label ADCO, got %s", dataset.Label)
6565
}
6666

67-
if dataset.Data != "BASE" {
68-
t.Errorf("Expected data BASE, got %s", dataset.Data)
67+
if dataset.Data != "021528603314" {
68+
t.Errorf("Expected data 021528603314, got %s", dataset.Data)
6969
}
7070

7171
if dataset.Valid != true {
72-
t.Errorf("Checksum invalid: %s", dataset.Checksum)
72+
t.Errorf("Checksum invalid, got %s", dataset.Checksum)
7373
}
7474
}
7575

@@ -80,13 +80,14 @@ func TestCalculateChecksum(t *testing.T) {
8080
}{
8181
{"IINST 002", "Y"}, // historical format
8282
{"IMAX 090", "H"},
83-
{"IINST\t002", "B"}, // standard format
83+
{"IINST\t002", "B"}, // standard format sans horodatage
84+
{"ADCO\t021528603314", "#"},
8485
}
8586

8687
for _, test := range tests {
8788
result := calculateChecksum(test.input)
8889
if string(result) != test.expected {
89-
t.Errorf("calculateChecksum(%q) = %s; expected %X", test.input, string(result), test.expected)
90+
t.Errorf("calculateChecksum(%q) = %s; expected %s", test.input, string(result), test.expected)
9091
}
9192
}
9293
}

0 commit comments

Comments
 (0)