ran gofmt -s

simplify things after having run gofmt -s
This commit is contained in:
Derek McQuay 2016-08-27 22:44:18 -07:00 committed by derek mcquay
parent 0f44030e53
commit 634cd011c0
5 changed files with 70 additions and 70 deletions

View File

@ -7,10 +7,10 @@ func TestOnLine(t *testing.T) {
p []Point
expected bool
}{
{[]Point{Point{1, 1}, Point{3, 3}, Point{2, 2}}, true},
{[]Point{Point{1, 1}, Point{3, 3}, Point{4, 4}}, false},
{[]Point{Point{-1, -1}, Point{-3, -3}, Point{-4, -4}}, false},
{[]Point{Point{-1, -1}, Point{-3, -3}, Point{-2, -2}}, true},
{[]Point{{1, 1}, {3, 3}, {2, 2}}, true},
{[]Point{{1, 1}, {3, 3}, {4, 4}}, false},
{[]Point{{-1, -1}, {-3, -3}, {-4, -4}}, false},
{[]Point{{-1, -1}, {-3, -3}, {-2, -2}}, true},
}
for _, rt := range onLineTest {
actual := onLine(rt.p[0], rt.p[1], rt.p[2])
@ -30,10 +30,10 @@ func TestLineIntersection(t *testing.T) {
l []line
expected Point
}{
{[]line{line{Point{0, 0}, Point{2, 2}}, line{Point{2, 0}, Point{0, 2}}}, Point{1, 1}},
{[]line{line{Point{0, 0}, Point{-2, -2}}, line{Point{-2, 0}, Point{0, -2}}}, Point{-1, -1}},
{[]line{line{Point{0, 0}, Point{-2, -2}}, line{Point{1, 0}, Point{1, -7}}}, Point{0, 0}},
{[]line{line{Point{5, 8}, Point{8, 5}}, line{Point{3, 7}, Point{7, 3}}}, Point{0, 0}},
{[]line{{Point{0, 0}, Point{2, 2}}, {Point{2, 0}, Point{0, 2}}}, Point{1, 1}},
{[]line{{Point{0, 0}, Point{-2, -2}}, {Point{-2, 0}, Point{0, -2}}}, Point{-1, -1}},
{[]line{{Point{0, 0}, Point{-2, -2}}, {Point{1, 0}, Point{1, -7}}}, Point{0, 0}},
{[]line{{Point{5, 8}, Point{8, 5}}, {Point{3, 7}, Point{7, 3}}}, Point{0, 0}},
}
for _, rt := range lineIntersectionTest {
actual, _ := lineIntersection(rt.l[0], rt.l[1])

View File

@ -10,10 +10,10 @@ func TestDistance(t *testing.T) {
p []Point
expected float64
}{
{[]Point{Point{1, 1}, Point{4, 5}}, 5},
{[]Point{Point{-1, -1}, Point{2, 3}}, 5},
{[]Point{Point{1, 1}, Point{2, 2}}, math.Sqrt(2)},
{[]Point{Point{1, 1}, Point{40, 20}}, math.Sqrt(1882)},
{[]Point{{1, 1}, {4, 5}}, 5},
{[]Point{{-1, -1}, {2, 3}}, 5},
{[]Point{{1, 1}, {2, 2}}, math.Sqrt(2)},
{[]Point{{1, 1}, {40, 20}}, math.Sqrt(1882)},
}
for _, rt := range distanceTest {
actual := distance(rt.p[0], rt.p[1])

View File

@ -90,16 +90,16 @@ func Adjacency(r1, r2 Rectangle) bool {
order2 := r2.inOrder()
sides1 := []line{
line{order1[0], order1[1]},
line{order1[0], order1[2]},
line{order1[3], order1[1]},
line{order1[3], order1[2]},
{order1[0], order1[1]},
{order1[0], order1[2]},
{order1[3], order1[1]},
{order1[3], order1[2]},
}
sides2 := []line{
line{order2[0], order2[1]},
line{order2[0], order2[2]},
line{order2[3], order2[1]},
line{order2[3], order2[2]},
{order2[0], order2[1]},
{order2[0], order2[2]},
{order2[3], order2[1]},
{order2[3], order2[2]},
}
for _, i := range sides1 {
@ -133,16 +133,16 @@ func Intersection(r1, r2 Rectangle) []Point {
order2 := r2.inOrder()
sides1 := []line{
line{order1[0], order1[1]},
line{order1[0], order1[2]},
line{order1[3], order1[1]},
line{order1[3], order1[2]},
{order1[0], order1[1]},
{order1[0], order1[2]},
{order1[3], order1[1]},
{order1[3], order1[2]},
}
sides2 := []line{
line{order2[0], order2[1]},
line{order2[0], order2[2]},
line{order2[3], order2[1]},
line{order2[3], order2[2]},
{order2[0], order2[1]},
{order2[0], order2[2]},
{order2[3], order2[1]},
{order2[3], order2[2]},
}
pts := []Point{}

View File

@ -7,13 +7,13 @@ func TestIsRect(t *testing.T) {
r Rectangle
expected bool
}{
{Rectangle{P1: Point{1, 1}, P2: Point{1, 2}, P3: Point{2, 1}, P4: Point{2, 2}}, true},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 1}, P3: Point{1, 0}, P4: Point{1, 1}}, true},
{Rectangle{P1: Point{0, 0}, P2: Point{0, -1}, P3: Point{-1, 0}, P4: Point{-1, -1}}, true},
{Rectangle{P1: Point{1.5, 1.5}, P2: Point{1.5, 3.5}, P3: Point{3.5, 1.5}, P4: Point{3.5, 3.5}}, true},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 3}, P3: Point{2, 0}, P4: Point{2, 3}}, true},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 100}, P3: Point{-1, 0}, P4: Point{0, 23}}, false},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 0}, P3: Point{0, 0}, P4: Point{0, 0}}, false},
{Rectangle{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}, true},
{Rectangle{Point{0, 0}, Point{0, 1}, Point{1, 0}, Point{1, 1}}, true},
{Rectangle{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}, true},
{Rectangle{Point{1.5, 1.5}, Point{1.5, 3.5}, Point{3.5, 1.5}, Point{3.5, 3.5}}, true},
{Rectangle{Point{0, 0}, Point{0, 3}, Point{2, 0}, Point{2, 3}}, true},
{Rectangle{Point{0, 0}, Point{0, 100}, Point{-1, 0}, Point{0, 23}}, false},
{Rectangle{Point{0, 0}, Point{0, 0}, Point{0, 0}, Point{0, 0}}, false},
}
for _, rt := range isRectTests {
actual := rt.r.IsRect()
@ -33,12 +33,12 @@ func TestSize(t *testing.T) {
r Rectangle
expected float64
}{
{Rectangle{P1: Point{1, 1}, P2: Point{1, 2}, P3: Point{2, 1}, P4: Point{2, 2}}, 1},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 1}, P3: Point{1, 0}, P4: Point{1, 1}}, 1},
{Rectangle{P1: Point{0, 0}, P2: Point{0, -1}, P3: Point{-1, 0}, P4: Point{-1, -1}}, 1},
{Rectangle{P1: Point{1.5, 1.5}, P2: Point{1.5, 3.5}, P3: Point{3.5, 1.5}, P4: Point{3.5, 3.5}}, 4},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 3}, P3: Point{2, 0}, P4: Point{2, 3}}, 6},
{Rectangle{P1: Point{0, 0}, P2: Point{0, 100}, P3: Point{100, 0}, P4: Point{100, 100}}, 10000},
{Rectangle{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}, 1},
{Rectangle{Point{0, 0}, Point{0, 1}, Point{1, 0}, Point{1, 1}}, 1},
{Rectangle{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}, 1},
{Rectangle{Point{1.5, 1.5}, Point{1.5, 3.5}, Point{3.5, 1.5}, Point{3.5, 3.5}}, 4},
{Rectangle{Point{0, 0}, Point{0, 3}, Point{2, 0}, Point{2, 3}}, 6},
{Rectangle{Point{0, 0}, Point{0, 100}, Point{100, 0}, Point{100, 100}}, 10000},
}
for _, rt := range sizeTests {
actual := rt.r.size()
@ -60,26 +60,26 @@ func TestContainment(t *testing.T) {
}{
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}},
true,
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{1, 1}, Point{1, 2}, Point{2, 1}, Point{2, 2}}},
true,
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}}},
false,
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{3, 3}, Point{3, 4}, Point{4, 3}, Point{4, 4}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{3, 3}, Point{3, 4}, Point{4, 3}, Point{4, 4}}},
false,
},
}
@ -103,32 +103,32 @@ func TestAdjacency(t *testing.T) {
}{
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{2, 2}, Point{2, 3}, Point{3, 2}, Point{3, 3}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{2, 2}, Point{2, 3}, Point{3, 2}, Point{3, 3}}},
true,
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{1, 3}, Point{2, 3}, Point{1, 4}, Point{2, 4}}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{1, 3}, Point{2, 3}, Point{1, 4}, Point{2, 4}}},
true,
},
{
[]Rectangle{
Rectangle{Point{2, 2}, Point{2, 3}, Point{3, 2}, Point{3, 3}},
Rectangle{Point{1, 3}, Point{2, 3}, Point{1, 4}, Point{2, 4}}},
{Point{2, 2}, Point{2, 3}, Point{3, 2}, Point{3, 3}},
{Point{1, 3}, Point{2, 3}, Point{1, 4}, Point{2, 4}}},
false,
},
{
[]Rectangle{
Rectangle{Point{-2, -2}, Point{-2, -3}, Point{-3, -2}, Point{-3, -3}},
Rectangle{Point{-1, -3}, Point{-2, -3}, Point{-1, -4}, Point{-2, -4}}},
{Point{-2, -2}, Point{-2, -3}, Point{-3, -2}, Point{-3, -3}},
{Point{-1, -3}, Point{-2, -3}, Point{-1, -4}, Point{-2, -4}}},
false,
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, -3}, Point{-3, 0}, Point{-3, -3}},
Rectangle{Point{-2, -2}, Point{-2, -3}, Point{-3, -2}, Point{-3, -3}}},
{Point{0, 0}, Point{0, -3}, Point{-3, 0}, Point{-3, -3}},
{Point{-2, -2}, Point{-2, -3}, Point{-3, -2}, Point{-3, -3}}},
true,
},
}
@ -152,20 +152,20 @@ func TestIntersection(t *testing.T) {
}{
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{2, 1}, Point{2, 2}, Point{4, 1}, Point{4, 2}}},
[]Point{Point{3, 1}, Point{3, 2}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{2, 1}, Point{2, 2}, Point{4, 1}, Point{4, 2}}},
[]Point{{3, 1}, {3, 2}},
},
{
[]Rectangle{
Rectangle{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
Rectangle{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}},
[]Point{Point{0, 0}},
{Point{0, 0}, Point{0, 3}, Point{3, 0}, Point{3, 3}},
{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}},
[]Point{{0, 0}},
},
{
[]Rectangle{
Rectangle{Point{2, 1}, Point{2, 2}, Point{4, 1}, Point{4, 2}},
Rectangle{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}},
{Point{2, 1}, Point{2, 2}, Point{4, 1}, Point{4, 2}},
{Point{0, 0}, Point{0, -1}, Point{-1, 0}, Point{-1, -1}}},
[]Point{},
},
}

View File

@ -7,9 +7,9 @@ func TestSizeTriangle(t *testing.T) {
pts []Point
expected float64
}{
{[]Point{Point{-2, 3}, Point{-3, -1}, Point{3, -2}}, 12.5},
{[]Point{Point{0, 0}, Point{1, 1}, Point{0, 1}}, 0.5},
{[]Point{Point{10, 14}, Point{20, 15}, Point{12, 52}}, 189},
{[]Point{{-2, 3}, {-3, -1}, {3, -2}}, 12.5},
{[]Point{{0, 0}, {1, 1}, {0, 1}}, 0.5},
{[]Point{{10, 14}, {20, 15}, {12, 52}}, 189},
}
for _, rt := range sizeTriangleTests {
actual := sizeTriangle(rt.pts[0], rt.pts[1], rt.pts[2])