forked from google/gxui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsize_test.go
36 lines (30 loc) · 1.05 KB
/
size_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package math
import test "github.com/google/gxui/testing"
import "testing"
func TestSizeEdgeAlignedFitTopEdge(t *testing.T) {
outer := CreateRect(0, 0, 100, 100)
s := Size{10, 10}
p := Point{50, 50}
test.AssertEquals(t, CreateRect(45, 50, 55, 60), s.EdgeAlignedFit(outer, p))
}
func TestSizeEdgeAlignedFitBottomEdge(t *testing.T) {
outer := CreateRect(0, 0, 100, 100)
s := Size{10, 10}
p := Point{50, 95}
test.AssertEquals(t, CreateRect(45, 85, 55, 95), s.EdgeAlignedFit(outer, p))
}
func TestSizeEdgeAlignedFitLeftEdge(t *testing.T) {
outer := CreateRect(0, 0, 100, 100)
s := Size{10, 80}
p := Point{5, 50}
test.AssertEquals(t, CreateRect(5, 10, 15, 90), s.EdgeAlignedFit(outer, p))
}
func TestSizeEdgeAlignedFitRightEdge(t *testing.T) {
outer := CreateRect(0, 0, 100, 100)
s := Size{10, 80}
p := Point{95, 50}
test.AssertEquals(t, CreateRect(85, 10, 95, 90), s.EdgeAlignedFit(outer, p))
}