Ejemplo n.º 1
0
        public void FullUTF16CharacterTestCoverage()
        {
            StringBuilder builder = new StringBuilder();

            Util.TestDeserialization(builder, '\0', @"""\0""");
            Util.TestDeserialization(builder, '\n', @"""\n""");
            Util.TestDeserialization(builder, '\r', @"""\r""");
            Util.TestDeserialization(builder, '\t', @"""\t""");
            Util.TestDeserialization(builder, '\\', @"""\\""");
            Util.TestDeserialization(builder, '\xab', @"""\xab""");
            Util.TestDeserialization(builder, '\x9F', @"""\x9F""");
            Util.TestDeserialization(builder, '\uabCe', @"""\uabCe""");
            Util.TestDeserialization(builder, '\u9F3C', @"""\u9F3C""");
            //Util.TestDeserialization(builder, '\a', @"""\a""");
            //Util.TestDeserialization(builder, '\b', @"""\b""");
            //Util.TestDeserialization(builder, '\f', @"""\f""");
            //Util.TestDeserialization(builder, '\v', @"""\v""");

            for (Int32 cAsInt = 0; cAsInt <= 65535; cAsInt++)
            {
                Char c = (Char)cAsInt;

                String seralizationString = c.SerializeChar();

                Object newObject = null;

                Int32 offset = -1;
                try
                {
                    offset = Sos.Deserialize(out newObject, typeof(Char), seralizationString, 0, seralizationString.Length);
                }
                catch (Exception e)
                {
                    throw new Exception(String.Format("Deserialization failed: {0}. Serialized string was '{1}'", e, seralizationString), e);
                }

                //Console.WriteLine("Before Serialization '{0}' ({1}) SerializeString '{2}' After '{3}' ({4})",
                //    c, typeof(Char), seralizationString, newObject, newObject.GetType());

                Assert.AreEqual(seralizationString.Length, offset);

                String diffMessage = c.Diff(newObject);
                if (diffMessage != null)
                {
                    Assert.Fail(diffMessage);
                }
            }
        }