public void Test_S2Cap_EncodeDecode() { S2Cap cap = S2Cap.FromCenterHeight(new S2Point(3, 2, 1).Normalize(), 1); Encoder encoder = new(); cap.Encode(encoder); var decoder = encoder.Decoder(); var(success, decoded_cap) = S2Cap.Decode(decoder); Assert.True(success); Assert.Equal(cap, decoded_cap); }
// Encode/Decode not yet implemented for these types. // S2R2Rect // S2RegionIntersection // S2RegionUnion // TestEncodeDecode tests that the input encodes to match the expected // golden data, and then returns the decode of the data into dst. private static Region TestEncodeDecode <Region>(string golden, Region src) where Region : IEncoder, IS2Region <Region> { Encoder encoder = new(); src.Encode(encoder); var str = encoder.HexString(); Assert.Equal(golden, str); var decoder = encoder.Decoder(); Dictionary <Type, Func <Decoder, (bool, IEncoder?)> > funcDict = new() { { typeof(S2Cap), (d) => S2Cap.Decode(d) }, { typeof(S2Cell), (d) => S2Cell.Decode(d) },