-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathobject_type_test.go
More file actions
37 lines (33 loc) · 871 Bytes
/
object_type_test.go
File metadata and controls
37 lines (33 loc) · 871 Bytes
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
package gitobj
import (
"math"
"testing"
"github.com/stretchr/testify/assert"
)
func TestObjectTypeFromString(t *testing.T) {
for str, typ := range map[string]ObjectType{
"blob": BlobObjectType,
"tree": TreeObjectType,
"commit": CommitObjectType,
"tag": TagObjectType,
"something else": UnknownObjectType,
} {
t.Run(str, func(t *testing.T) {
assert.Equal(t, typ, ObjectTypeFromString(str))
})
}
}
func TestObjectTypeToString(t *testing.T) {
for typ, str := range map[ObjectType]string{
BlobObjectType: "blob",
TreeObjectType: "tree",
CommitObjectType: "commit",
TagObjectType: "tag",
UnknownObjectType: "unknown",
ObjectType(math.MaxUint8): "<unknown>",
} {
t.Run(str, func(t *testing.T) {
assert.Equal(t, str, typ.String())
})
}
}