From 634cd011c083e9c723f4771f97255bb8002bb2b2 Mon Sep 17 00:00:00 2001 From: Derek McQuay Date: Sat, 27 Aug 2016 22:44:18 -0700 Subject: [PATCH] ran gofmt -s simplify things after having run gofmt -s --- line_test.go | 16 +++++----- point_test.go | 8 ++--- rectangle.go | 32 +++++++++---------- rectangle_test.go | 78 +++++++++++++++++++++++------------------------ triangle_test.go | 6 ++-- 5 files changed, 70 insertions(+), 70 deletions(-) diff --git a/line_test.go b/line_test.go index 4f398fa..90a1ed3 100644 --- a/line_test.go +++ b/line_test.go @@ -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]) diff --git a/point_test.go b/point_test.go index b31c0da..3c3f8d6 100644 --- a/point_test.go +++ b/point_test.go @@ -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]) diff --git a/rectangle.go b/rectangle.go index 4f45bf1..45aa7d7 100644 --- a/rectangle.go +++ b/rectangle.go @@ -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{} diff --git a/rectangle_test.go b/rectangle_test.go index 6b13844..409db36 100644 --- a/rectangle_test.go +++ b/rectangle_test.go @@ -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{}, }, } diff --git a/triangle_test.go b/triangle_test.go index 2c301ec..ae431f1 100644 --- a/triangle_test.go +++ b/triangle_test.go @@ -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])