public void testNeighbors()
        {
            Trace.WriteLine("TestNeighbors");

            // Check the edge neighbors of face 1.
            int[] outFaces = { 5, 3, 2, 0 };

            var faceNbrs = S2CellId.FromFacePosLevel(1, 0, 0).GetEdgeNeighbors();

            for (var i = 0; i < 4; ++i)
            {
                Assert.True(faceNbrs[i].IsFace);
                JavaAssert.Equal(faceNbrs[i].Face, outFaces[i]);
            }

            // Check the vertex neighbors of the center of face 2 at level 5.
            var nbrs = new List <S2CellId>();

            S2CellId.FromPoint(new S2Point(0, 0, 1)).GetVertexNeighbors(5, nbrs);
            nbrs.Sort();
            for (var i = 0; i < 4; ++i)
            {
                JavaAssert.Equal(nbrs[i], S2CellId.FromFaceIj(
                                     2, (1 << 29) - (i < 2 ? 1 : 0), (1 << 29) - ((i == 0 || i == 3) ? 1 : 0)).ParentForLevel(5));
            }
            nbrs.Clear();

            // Check the vertex neighbors of the corner of faces 0, 4, and 5.
            var id = S2CellId.FromFacePosLevel(0, 0, S2CellId.MaxLevel);

            id.GetVertexNeighbors(0, nbrs);
            nbrs.Sort();

            JavaAssert.Equal(nbrs.Count, 3);
            JavaAssert.Equal(nbrs[0], S2CellId.FromFacePosLevel(0, 0, 0));
            JavaAssert.Equal(nbrs[1], S2CellId.FromFacePosLevel(4, 0, 0));
            JavaAssert.Equal(nbrs[2], S2CellId.FromFacePosLevel(5, 0, 0));

            // Check that GetAllNeighbors produces results that are consistent
            // with GetVertexNeighbors for a bunch of random cells.
            for (var i = 0; i < 1000; ++i)
            {
                var id1    = getRandomCellId();
                var toTest = id1;
                if (id1.IsLeaf)
                {
                    toTest = id1.Parent;
                }

                // TestAllNeighbors computes approximately 2**(2*(diff+1)) cell id1s,
                // so it's not reasonable to use large values of "diff".
                var maxDiff = Math.Min(6, S2CellId.MaxLevel - toTest.Level - 1);
                var level   = toTest.Level + random(maxDiff);
                testAllNeighbors(toTest, level);
            }
        }