// 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) },
public void Test_S2Cell_EncodeDecode() { S2Cell orig_cell = new(S2LatLng.FromDegrees(40.7406264, -74.0029963)); Encoder encoder = new(); orig_cell.Encode(encoder); var decoder = encoder.Decoder(); var(_, decoded_cellNull) = S2Cell.Decode(decoder); var decoded_cell = decoded_cellNull !.Value; Assert.Equal(orig_cell, decoded_cell); Assert.Equal(orig_cell.Face, decoded_cell.Face); Assert.Equal(orig_cell.Level, decoded_cell.Level); Assert.Equal(orig_cell.Orientation, decoded_cell.Orientation); Assert.Equal(orig_cell.Id, decoded_cell.Id); Assert.Equal(orig_cell.BoundUV, decoded_cell.BoundUV); }