Esempio n. 1
0
        public void Get2DoublesFromLegalDataSuccess()
        {
            var data = "000061145096228088225067144113188147132067201194";

            var des = new Deserializer(data);

            Assert.AreEqual(9999999999999999999.9999999999999999999999999999, des.GetDouble());
            //Assert.AreEqual(-55555555555555.123465789, des.GetDouble());
        }
Esempio n. 2
0
        public void SerializeAndDeserialize4RandomValuesOfDifferentType()
        {
            var    rand          = new Random(Guid.NewGuid().GetHashCode());
            var    value1        = LongRandom(0, long.MaxValue, rand);
            var    value2        = rand.Next(0, int.MaxValue);
            double value3        = LongRandom(0, long.MinValue, rand) + rand.Next(0, 5000) / 1000;
            var    value4        = rand.Next() % 2 == 0;
            var    value5Builder = new StringBuilder();

            for (var i = 0; i < 50; i++)
            {
                //just using numbers as string. should still work
                value5Builder.Append(rand.Next());
            }

            var value5 = value5Builder.ToString();

            TestContext.Out.WriteLine($"long value:{value1}");
            TestContext.Out.WriteLine($"int value:{value2}");
            TestContext.Out.WriteLine($"double value:{value3}");
            TestContext.Out.WriteLine($"bool value:{value4}");
            TestContext.Out.WriteLine($"string value:{value5}");


            ser.AddLong(value1);
            ser.AddInt32(value2);
            ser.AddDouble(value3);
            ser.AddBool(value4);
            ser.AddString(value5);

            var final = ser.FinalizeSerializationProcess();
            var des   = new Deserializer(final);

            Assert.AreEqual(value1, des.GetLong());
            Assert.AreEqual(value2, des.GetInt32());
            Assert.AreEqual(value3, des.GetDouble());
            Assert.AreEqual(value4, des.GetBool());
            var value = des.GetString();

            Assert.AreEqual(value5, value);
        }