-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add setter to the version scheme type (#25)
Fix #24
- Loading branch information
1 parent
0446ddb
commit 72b85bf
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2020 Contributors to the Veraison project. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package swid | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestVersionScheme_Set(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
tv uint64 | ||
expected error | ||
}{ | ||
{ | ||
name: "known codepoints (1)", | ||
tv: VersionSchemeMultipartNumeric, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "known codepoints (2)", | ||
tv: VersionSchemeMultipartNumericSuffix, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "known codepoints (3)", | ||
tv: VersionSchemeAlphaNumeric, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "known codepoints (4)", | ||
tv: VersionSchemeDecimal, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "known codepoints (5)", | ||
tv: VersionSchemeSemVer, | ||
expected: nil, | ||
}, | ||
{ | ||
name: "unknown codepoint", | ||
tv: 19283937, | ||
expected: errors.New("unknown version scheme 19283937"), | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
var u VersionScheme | ||
actual := u.SetCode(test.tv) | ||
assert.Equal(t, test.expected, actual) | ||
}) | ||
} | ||
} |