@@ -21,19 +21,61 @@ func TestHorizontalLineTest(t *testing.T) {
2121
2222 for _ , b := range allblobies .Objects {
2323 if b .IsCrossedTheLine (horizontalLine [0 ][1 ], horizontalLine [0 ][0 ], horizontalLine [1 ][0 ], direction ) {
24- t .Logf ("Correct when direction is TO US" )
24+ t .Logf ("[HORIZONTAL] Correct when direction is TO US" )
2525 } else {
26- t .Logf ( " Incorrect when direction is TO US" )
26+ t .Error ( "[HORIZONTAL] Incorrect when direction is TO US" )
2727 }
2828
2929 if b .IsCrossedTheLine (horizontalLine [0 ][1 ], horizontalLine [0 ][0 ], horizontalLine [1 ][0 ], ! direction ) {
30- t .Logf ( " Incorrect when direction is FROM US" )
30+ t .Error ( "[HORIZONTAL] Incorrect when direction is FROM US" )
3131 } else {
32- t .Logf ("Correct when direction is FROM US" )
32+ t .Logf ("[HORIZONTAL] Correct when direction is FROM US" )
3333 }
3434 }
3535}
3636
3737func TestObliqueLineTest (t * testing.T ) {
38+ shoudlCrossObliqueLine := [][]int {
39+ []int {4 , 35 },
40+ []int {71 , 31 },
41+ }
42+ shoudlNOTCrossObliqueLine := [][]int {
43+ []int {4 , 35 },
44+ []int {71 , 45 },
45+ }
46+
47+ direction := true // true - TO us
48+ allblobies := NewBlobiesDefaults ()
49+
50+ simpleB_time0 := NewSimpleBlobie (image .Rect (26 , 8 , 44 , 18 ), nil )
51+ simpleB_time1 := NewSimpleBlobie (image .Rect (26 , 20 , 44 , 30 ), nil )
52+ simpleB_time2 := NewSimpleBlobie (image .Rect (26 , 32 , 44 , 42 ), nil )
53+
54+ allblobies .MatchToExisting ([]Blobie {simpleB_time0 , simpleB_time1 , simpleB_time2 })
3855
56+ for _ , b := range allblobies .Objects {
57+ if b .IsCrossedTheObliqueLine (shoudlCrossObliqueLine [0 ][0 ], shoudlCrossObliqueLine [0 ][1 ], shoudlCrossObliqueLine [1 ][0 ], shoudlCrossObliqueLine [1 ][1 ], direction ) {
58+ t .Logf ("[OBLIQUE] Correct when direction is TO US" )
59+ } else {
60+ t .Error ("[OBLIQUE ERR] Incorrect when direction is TO US" )
61+ }
62+
63+ if b .IsCrossedTheObliqueLine (shoudlCrossObliqueLine [0 ][0 ], shoudlCrossObliqueLine [0 ][1 ], shoudlCrossObliqueLine [1 ][0 ], shoudlCrossObliqueLine [1 ][1 ], ! direction ) {
64+ t .Error ("[OBLIQUE ERR] Incorrect when direction is FROM US" )
65+ } else {
66+ t .Logf ("[OBLIQUE] Correct when direction is FROM US" )
67+ }
68+
69+ if b .IsCrossedTheObliqueLine (shoudlNOTCrossObliqueLine [0 ][0 ], shoudlNOTCrossObliqueLine [0 ][1 ], shoudlNOTCrossObliqueLine [1 ][0 ], shoudlNOTCrossObliqueLine [1 ][1 ], direction ) {
70+ t .Error ("[OBLIQUE NOT CROSS ERR] Incorrect when direction is TO US" )
71+ } else {
72+ t .Logf ("[OBLIQUE NOT CROSS] Correct when direction is TO US" )
73+ }
74+
75+ if b .IsCrossedTheObliqueLine (shoudlNOTCrossObliqueLine [0 ][0 ], shoudlNOTCrossObliqueLine [0 ][1 ], shoudlNOTCrossObliqueLine [1 ][0 ], shoudlNOTCrossObliqueLine [1 ][1 ], ! direction ) {
76+ t .Error ("[OBLIQUE NOT CROSS ERR] Incorrect when direction is FROM US" )
77+ } else {
78+ t .Logf ("[OBLIQUE NOT CROSS] Correct when direction is FROM US" )
79+ }
80+ }
3981}
0 commit comments