blob: c5440015ed57b2ba6ee06e25c39c66e58ee56c02 (
plain)
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
|
// SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
package parser2v1
import (
"testing"
)
// ===== Helper function tests =====
func TestCanExtractSubvalues(t *testing.T) {
subkey, subvalue, err := extractSubs("SHA1: abc123")
if err != nil {
t.Errorf("got error when calling extractSubs: %v", err)
}
if subkey != "SHA1" {
t.Errorf("got %v for subkey", subkey)
}
if subvalue != "abc123" {
t.Errorf("got %v for subvalue", subvalue)
}
}
func TestReturnsErrorForInvalidSubvalueFormat(t *testing.T) {
_, _, err := extractSubs("blah")
if err == nil {
t.Errorf("expected error when calling extractSubs for invalid format (0 colons), got nil")
}
}
|