Merge pull request #68 from sgarciac/master

test(util): add tests for util/geometry
This commit is contained in:
Alexander Lukyanchikov 2019-10-06 22:46:56 -04:00 committed by GitHub
commit aadceceed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,52 @@
package util
import "testing"
import "image"
func TestGetRectLeftSideCenter(t *testing.T) {
rect := image.Rect(10, 10, 20, 20)
expected := image.Point{
X: 10,
Y: 15,
}
result := GetRectLeftSideCenter(rect)
if result != expected {
t.Errorf("GetRectLeftSideCenter was incorrect. Expected %v, got %v.", expected, result)
}
}
func TestGetRectRightSideCenter(t *testing.T) {
rect := image.Rect(10, 10, 20, 21)
expected := image.Point{
X: 20,
Y: 15,
}
result := GetRectRightSideCenter(rect)
if result != expected {
t.Errorf("GetRectRightSideCenter was incorrect. Expected %v, got %v.", expected, result)
}
}
func TestGetRectTopSideCenter(t *testing.T) {
rect := image.Rect(10, 10, 20, 20)
expected := image.Point{
X: 15,
Y: 10,
}
result := GetRectTopSideCenter(rect)
if result != expected {
t.Errorf("GetRectTopSideCenter was incorrect. Expected %v, got %v.", expected, result)
}
}
func TestGetRectBottomSideCenter(t *testing.T) {
rect := image.Rect(10, 9, 20, 20)
expected := image.Point{
X: 15,
Y: 20,
}
result := GetRectBottomSideCenter(rect)
if result != expected {
t.Errorf("GetRectBottomSideCenter was incorrect. Expected %v, got %v.", expected, result)
}
}