forked from agiledragon/ddd-sample-in-golang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffaebf3
commit 3791077
Showing
7 changed files
with
241 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package model | ||
|
||
import ( | ||
. "github.com/smartystreets/goconvey/convey" | ||
"testing" | ||
) | ||
|
||
func TestRingConnected(t *testing.T) { | ||
lines := []string{"abh", "acgi", "adfj", "aek", "bcde", "hgfe", "hijk"} | ||
ring_connected := ringOrderConnected(lines) | ||
Convey("TestRingConnected", t, func() { | ||
|
||
Convey("succ", func() { | ||
So(ring_connected([]Point("abc")...), ShouldBeTrue) | ||
So(ring_connected([]Point("bcgh")...), ShouldBeTrue) | ||
So(ring_connected([]Point("cdfg")...), ShouldBeTrue) | ||
So(ring_connected([]Point("abeg")...), ShouldBeTrue) | ||
So(ring_connected([]Point("abhg")...), ShouldBeTrue) | ||
So(ring_connected([]Point("defj")...), ShouldBeTrue) | ||
}) | ||
|
||
Convey("failed", func() { | ||
So(ring_connected([]Point("acf")...), ShouldBeFalse) | ||
So(ring_connected([]Point("bcg")...), ShouldBeFalse) | ||
So(ring_connected([]Point("defk")...), ShouldBeFalse) | ||
}) | ||
|
||
}) | ||
} | ||
|
||
func TestHasCrossConnected(t *testing.T) { | ||
lines := []string{"abh", "acgi", "adfj", "aek", "bcde", "hgfe", "hijk"} | ||
cross_connected := hasCrossConnected(lines) | ||
Convey("TestHasCrossConnected", t, func() { | ||
|
||
Convey("succ", func() { | ||
So(cross_connected("ag", "bd"), ShouldBeTrue) | ||
So(cross_connected("af", "ce"), ShouldBeTrue) | ||
So(cross_connected("af", "be"), ShouldBeTrue) | ||
So(cross_connected("ai", "eh"), ShouldBeTrue) | ||
}) | ||
|
||
Convey("failed", func() { | ||
So(cross_connected("bc", "hg"), ShouldBeFalse) | ||
So(cross_connected("fj", "ek"), ShouldBeFalse) | ||
}) | ||
|
||
}) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package model | ||
|
||
func IsTriangle(points Points, lines []Line) bool { | ||
ring_order_connected := ringOrderConnected(lines) | ||
in_same_line := inSameLine(lines) | ||
|
||
a := points[0] | ||
b := points[1] | ||
c := points[2] | ||
|
||
return ring_order_connected(a, b, c) && | ||
not(in_same_line(a, b, c)) | ||
} | ||
|
||
func IsQuadrangle(points Points, lines []Line) bool { | ||
ring_order_connected := ringOrderConnected(lines) | ||
cross_connected := hasCrossConnected(lines) | ||
in_same_line := inSameLine(lines) | ||
|
||
a := points[0] | ||
b := points[1] | ||
c := points[2] | ||
d := points[3] | ||
|
||
ring_order_connected_without_cross := func(w, x, y, z Point) bool { | ||
wx := Points([]Point{w, x}) | ||
yz := Points([]Point{y, z}) | ||
wz := Points([]Point{w, z}) | ||
xy := Points([]Point{x, y}) | ||
return ring_order_connected(w, x, y, z) && | ||
not(cross_connected(wx, yz)) && | ||
not(cross_connected(wz, xy)) | ||
|
||
} | ||
|
||
return ring_order_connected_without_cross(a, b, c, d) && | ||
not(in_same_line(a, b, c)) && | ||
not(in_same_line(a, b, d)) && | ||
not(in_same_line(a, c, d)) && | ||
not(in_same_line(b, c, d)) | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters