Exemplo n.º 1
0
    static void test_serialization()
    {
        Log("test_serialization");
        const int MaxPacketSize = 1024;
        var       serializer    = new TestSerializer();
        var       buffer        = new uint[MaxPacketSize / 4];
        var       writeStream   = new WriteStream();

        writeStream.Start(buffer);
        TestStruct input;

        input.bool_value = true;
        input.int_value  = -5;
        input.uint_value = 215;
        input.bits_value = 12345;
        serializer.WriteTestStruct(writeStream, ref input);
        writeStream.Finish();

        var packet     = writeStream.GetData();
        var readStream = new ReadStream();

        readStream.Start(packet);
        TestStruct output;

        serializer.ReadTestStruct(readStream, out output);
        readStream.Finish();

        AreEqual(input.bool_value, output.bool_value);
        AreEqual(input.int_value, output.int_value);
        AreEqual(input.uint_value, output.uint_value);
        AreEqual(input.bits_value, output.bits_value);
    }