Tests: Add unit tests

This commit is contained in:
graciousgrey 2023-07-24 14:02:18 +02:00
parent 69d302248c
commit 33b08f15e5
2 changed files with 14 additions and 0 deletions

View file

@ -35,4 +35,11 @@ func TestOpenJpeg(t *testing.T) {
t.Error("img must not be nil")
}
})
t.Run("filename empty", func(t *testing.T) {
img, err := OpenJpeg("", 0)
assert.Error(t, err)
assert.Equal(t, "filename missing", err.Error())
assert.Nil(t, img)
})
}

View file

@ -81,3 +81,10 @@ func TestParseQuality(t *testing.T) {
assert.Equal(t, Quality(100), ParseQuality("100"))
})
}
func TestQuality_String(t *testing.T) {
assert.Equal(t, "95", QualityBest.String())
assert.Equal(t, "92", QualityHigh.String())
assert.Equal(t, "75", QualityBad.String())
}