MCPcopy
hub / github.com/golang/geo / TestCellIDFromTokensErrorCases

Function TestCellIDFromTokensErrorCases

s2/cellid_test.go:391–425  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

389}
390
391func TestCellIDFromTokensErrorCases(t *testing.T) {
392 noneToken := CellID(0).ToToken()
393 if noneToken != "X" {
394 t.Errorf("CellID(0).Token() = %q, want X", noneToken)
395 }
396 noneID := CellIDFromToken(noneToken)
397 if noneID != CellID(0) {
398 t.Errorf("CellIDFromToken(%q) = %x, want 0", noneToken, uint64(noneID))
399 }
400
401 // Sentinel is invalid.
402 sentinel := SentinelCellID.ToToken()
403 if got, want := CellIDFromToken(sentinel), SentinelCellID; got != want {
404 t.Errorf("CellIDFromToken(%v) = %v, want %v", sentinel, got, want)
405 }
406
407 // Check an invalid face.
408 face7 := CellIDFromFace(7).ToToken()
409 if got, want := CellIDFromToken(face7), CellIDFromFace(7); got != want {
410 t.Errorf("CellIDFromToken(%v) = %v, want %v", face7, got, want)
411 }
412
413 tests := []string{
414 "876b e99",
415 "876bee99\n",
416 "876[ee99",
417 " 876bee99",
418 }
419 for _, test := range tests {
420 ci := CellIDFromToken(test)
421 if uint64(ci) != 0 {
422 t.Errorf("CellIDFromToken(%q) = %x, want 0", test, uint64(ci))
423 }
424 }
425}
426
427func TestIJLevelToBoundUV(t *testing.T) {
428 maxIJ := 1<<MaxLevel - 1

Callers

nothing calls this directly

Calls 4

CellIDTypeAlias · 0.85
CellIDFromTokenFunction · 0.85
CellIDFromFaceFunction · 0.85
ToTokenMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…