7 "github.com/stretchr/testify/assert"
10 func TestObjectTypeFromString(t *testing.T) {
11 for str, typ := range map[string]ObjectType{
12 "blob": BlobObjectType,
13 "tree": TreeObjectType,
14 "commit": CommitObjectType,
16 "something else": UnknownObjectType,
18 t.Run(str, func(t *testing.T) {
19 assert.Equal(t, typ, ObjectTypeFromString(str))
24 func TestObjectTypeToString(t *testing.T) {
25 for typ, str := range map[ObjectType]string{
26 BlobObjectType: "blob",
27 TreeObjectType: "tree",
28 CommitObjectType: "commit",
30 UnknownObjectType: "unknown",
31 ObjectType(math.MaxUint8): "<unknown>",
33 t.Run(str, func(t *testing.T) {
34 assert.Equal(t, str, typ.String())