mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-26 15:02:52 -05:00
41 lines
881 B
Go
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())
|
|
}
|
|
}
|