Files
opencloud/thumbnails/pkg/thumbnail/resolution/resolution_test.go
A.Unger 530336a826 Add 'thumbnails/' from commit '2ebf7b2f23af96b3b499c401fe5498a9349403d8'
git-subtree-dir: thumbnails
git-subtree-mainline: ccc651a11e
git-subtree-split: 2ebf7b2f23
2020-09-18 13:02:40 +02:00

41 lines
881 B
Go

package resolution
import "testing"
func TestParseWithEmptyString(t *testing.T) {
_, err := Parse("")
if err == nil {
t.Error("Parse with empty string should return an error.")
}
}
func TestParseWithInvalidWidth(t *testing.T) {
_, err := Parse("invalidx42")
if err == nil {
t.Error("Parse with invalid width should return an error.")
}
}
func TestParseWithInvalidHeight(t *testing.T) {
_, err := Parse("42xinvalid")
if err == nil {
t.Error("Parse with invalid height should return an error.")
}
}
func TestParse(t *testing.T) {
rStr := "42x23"
r, _ := Parse(rStr)
if r.Width != 42 || r.Height != 23 {
t.Errorf("Expected resolution %s got %s", rStr, r.String())
}
}
func TestString(t *testing.T) {
r := Resolution{Width: 42, Height: 23}
expected := "42x23"
if r.String() != expected {
t.Errorf("Expected string %s got %s", expected, r.String())
}
}