Exemplo n.º 1
0
        public void Test_S2CellUnion_EncodeDecodeEmpty()
        {
            S2CellUnion empty_cell_union = new();

            Encoder encoder = new();

            empty_cell_union.Encode(encoder);
            var decoder = encoder.Decoder();

            var(success, decoded_cell_union) = S2CellUnion.Decode(decoder);
            Assert.True(success);
            Assert.Equal(empty_cell_union, decoded_cell_union);
        }
Exemplo n.º 2
0
        public void Test_S2CellUnion_EncodeDecode()
        {
            var cell_ids = new List <S2CellId> {
                new S2CellId(0x33),
                new S2CellId(0x8e3748fab),
                new S2CellId(0x91230abcdef83427)
            };
            var cell_union = S2CellUnion.FromVerbatim(cell_ids);

            Encoder encoder = new();

            cell_union.Encode(encoder);
            var decoder = encoder.Decoder();

            var(success, decoded_cell_union) = S2CellUnion.Decode(decoder);
            Assert.True(success);
            Assert.Equal(cell_union, decoded_cell_union);
        }
Exemplo n.º 3
0
        public void Test_S2CellUnion_RefuseToDecode()
        {
            List <S2CellId> cellids = new();
            S2CellId        id      = S2CellId.Begin(S2.kMaxCellLevel);

            for (int i = 0; i <= S2CellUnion.Union_decode_max_num_cells; ++i)
            {
                cellids.Add(id);
                id = id.Next();
            }
            S2CellUnion cell_union = S2CellUnion.FromVerbatim(cellids);
            Encoder     encoder    = new();

            cell_union.Encode(encoder);
            var decoder = encoder.Decoder();

            var(success, _) = S2CellUnion.Decode(decoder);
            Assert.False(success);
        }