コード例 #1
0
        //[Fact(Skip = "Skipped")]
        public void VariantBitConverterShortTest()
        {
            Util.Log("VariantBitConverterShortTest");

            Random random = new Random();

            MemoryStream stream = new MemoryStream();
            long         size   = 0;

            for (int i = 0; i < 1000; i++)
            {
                stream.Position = 0;

                short src = (short)random.Next(short.MinValue, short.MaxValue);

                int s = 0;
                VarintBitConverter.SerializeShort(src, stream, out s);
                size            = stream.Position;
                stream.Position = 0;

                short dst = VarintBitConverter.ToShort(stream, out s);

                //Util.Log("src:" + src + ", dst:" + dst + ", size:" + size);

                if (src != dst)
                {
                    throw new InvalidProgramException("index:" + i + ", src:" + src + ", dst:" + dst + ", size:" + size);
                }
            }
        }