mirror of https://github.com/periph/devices
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
// Copyright 2021 The Periph Authors. All rights reserved.
|
|
// Use of this source code is governed under the Apache License, Version 2.0
|
|
// that can be found in the LICENSE file.
|
|
|
|
package videosink
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestImageFormat(t *testing.T) {
|
|
for _, tc := range []struct {
|
|
format ImageFormat
|
|
wantString string
|
|
wantMimeType string
|
|
}{
|
|
{
|
|
format: ImageFormat(-1),
|
|
wantString: "-1",
|
|
wantMimeType: "application/octet-stream",
|
|
},
|
|
{
|
|
wantString: "PNG",
|
|
wantMimeType: "image/png",
|
|
},
|
|
{
|
|
format: DefaultFormat,
|
|
wantString: "PNG",
|
|
wantMimeType: "image/png",
|
|
},
|
|
{
|
|
format: PNG,
|
|
wantString: "PNG",
|
|
wantMimeType: "image/png",
|
|
},
|
|
{
|
|
format: JPEG,
|
|
wantString: "JPEG",
|
|
wantMimeType: "image/jpeg",
|
|
},
|
|
} {
|
|
t.Run(fmt.Sprint(tc), func(t *testing.T) {
|
|
if got := tc.format.String(); got != tc.wantString {
|
|
t.Errorf("String() returned %q, want %q", got, tc.wantString)
|
|
}
|
|
|
|
if got := tc.format.mimeType(); got != tc.wantMimeType {
|
|
t.Errorf("mimeType() returned %q, want %q", got, tc.wantMimeType)
|
|
}
|
|
})
|
|
}
|
|
}
|