Beispiel #1
0
        public void Test_S2PointRegionTest_DecodeUnitLength()
        {
            // Ensure that we have the right format for the next test.
            Encoder encoder = new();

            encoder.Ensure(1 + 3 * 8);

            encoder.Put8(1);  // version number
            encoder.PutDouble(1.0);
            encoder.PutDouble(0.0);
            encoder.PutDouble(0.0);

            var decoder = encoder.Decoder();

            // S2PointRegion r = new S2PointRegion(new S2Point(-1, 0, 0));
            var(success, _) = S2PointRegion.Decode(decoder);
            Assert.True(success);
        }
Beispiel #2
0
        public void Test_S2PointRegionTest_DecodeNonUnitLength()
        {
            // Ensure that a decode of a non-unit length vector returns false,
            // rather than S2_DCHECK fails.
            Encoder encoder = new();

            encoder.Ensure(1 + 3 * 8);

            encoder.Put8(1);  // version number
            encoder.PutDouble(1.0);
            encoder.PutDouble(1.0);
            encoder.PutDouble(1.0);

            var decoder = encoder.Decoder();

            // S2PointRegion r = new(new S2Point(-1, 0, 0));
            var(success, _) = S2PointRegion.Decode(decoder);
            Assert.False(success);
        }
Beispiel #3
0
        public void Test_S2PointRegionTest_EncodeAndDecode()
        {
            S2Point       p = new(0.6, 0.8, 0);
            S2PointRegion r = new(p);

            Encoder encoder = new();

            r.Encode(encoder);

            var decoder = encoder.Decoder();

            // S2PointRegion decoded_r = new S2PointRegion(new S2Point(1, 0, 0));
            var(_, decoded_r) = S2PointRegion.Decode(decoder);
            S2Point decoded_p = decoded_r !.Value.Point;

            Assert.Equal(0.6, decoded_p[0]);
            Assert.Equal(0.8, decoded_p[1]);
            Assert.Equal(0.0, decoded_p[2]);
        }