Skip to content

Commit 8e0a9ee

Browse files
committed
Restore check on childPos to no longer test for unreachable negative values.
Fix two lint errors.
1 parent 2bb09a9 commit 8e0a9ee

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

s2/cellid.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,9 @@ func CellIDFromString(s string) CellID {
356356
}
357357
id := CellIDFromFace(face)
358358
for i := 2; i < len(s); i++ {
359-
childPos := s[i] - '0'
360-
if childPos < 0 || childPos > 3 {
359+
var childPos byte = s[i] - '0'
360+
// Bytes are non-negative.
361+
if childPos > 3 {
361362
return CellID(0)
362363
}
363364
id = id.Children()[childPos]

s2/edge_distances_test.go

+15-12
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ func TestEdgeDistanceUpdateMinInteriorDistanceMaxError(t *testing.T) {
529529
}
530530
a1 := PointOnLine(a0, randomPoint(), length)
531531

532-
// TODO(ericv): The error bound holds for antipodal points, but the S2
532+
// TODO(rsned): The error bound holds for antipodal points, but the S2
533533
// predicates used to test the error do not support antipodal points yet.
534534
if a1.Vector == a0.Mul(-1) {
535535
continue
@@ -545,22 +545,25 @@ func TestEdgeDistanceUpdateMinInteriorDistanceMaxError(t *testing.T) {
545545
minDist := s1.InfChordAngle()
546546

547547
var ok bool
548-
if minDist, ok = UpdateMinInteriorDistance(x, a0, a1, minDist); !ok {
548+
// TODO(rsned): The first param here should be minDist which is needed
549+
// for the two commented out tests below. When they are implemented
550+
// return this to "if minDist, ok == Update...."
551+
if _, ok = UpdateMinInteriorDistance(x, a0, a1, minDist); !ok {
549552
iter--
550553
continue
551554
}
552555
// TODO(rsned): Uncomment once predicates has CompareEdgeDistance
553556
/*
554-
maxErr := minUpdateDistanceMaxError(minDist)
555-
if got := CompareEdgeDistance(x, a0, a1, minDist.Expanded(maxErr)); got > 0 {
556-
t.Errorf("CompareEdgeDistance(%v, %v, %v, %v) = got, want <= 0",
557-
x, a0, a1, minDist.Expanded(maxErr), got)
558-
559-
}
560-
if got := CompareEdgeDistance(x, a0, a1, minDist.Expanded(-maxErr)); got < 0 {
561-
t.Errorf("CompareEdgeDistance(%v, %v, %v, %v) = got, want >= 0",
562-
x, a0, a1, minDist.Expanded(-maxErr), got)
563-
}
557+
maxErr := minUpdateDistanceMaxError(minDist)
558+
if got := CompareEdgeDistance(x, a0, a1, minDist.Expanded(maxErr)); got > 0 {
559+
t.Errorf("CompareEdgeDistance(%v, %v, %v, %v) = got, want <= 0",
560+
x, a0, a1, minDist.Expanded(maxErr), got)
561+
562+
}
563+
if got := CompareEdgeDistance(x, a0, a1, minDist.Expanded(-maxErr)); got < 0 {
564+
t.Errorf("CompareEdgeDistance(%v, %v, %v, %v) = got, want >= 0",
565+
x, a0, a1, minDist.Expanded(-maxErr), got)
566+
}
564567
*/
565568
}
566569
}

s2/predicates.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ func exactIntersectionOrdering(a, b, c, d, m, n r3.PreciseVector) int {
10231023
//
10241024
// > gappa proof.gappa
10251025
// Results:
1026-
//| diff_ - diff| in [0, 1145679351550454559b-107 {7.06079e-15, 2^(-47.0091)}]
1026+
// | diff_ - diff| in [0, 1145679351550454559b-107 {7.06079e-15, 2^(-47.0091)}]
10271027
//
10281028
// >>> 1145679351550454559*2**-107/2**-52
10291029
// 31.79898987322334

0 commit comments

Comments
 (0)