Ejemplo n.º 1
0
        static String GetMessage(Utf8ExceptionType type)
        {
            switch (type)
            {
            case Utf8ExceptionType.StartedInsideCodePoint: return(StartedInsideCodePointMessage);

            case Utf8ExceptionType.MissingBytes: return(MissingBytesMessage);

            case Utf8ExceptionType.OutOfRange: return(OutOfRangeMessage);
            }
            return(GenericMessage);
        }
Ejemplo n.º 2
0
        void TestInvalidUtf8(Utf8ExceptionType expectedError, params Byte[] s)
        {
            UInt32 start = 0;
            UInt32 limit = (UInt32)s.Length;

            try
            {
                var decoded = Utf8.Decode(s, ref start, limit);
                Assert.Fail("expected error '%s' but no error was thrown", expectedError);
            } catch (Utf8Exception e)
            {
                Assert.AreEqual(expectedError, e.type, String.Format("expected error '{0}' but got '{1}'", expectedError, e.type));
            }

            Console.WriteLine("got expected error '{0}'", expectedError);
        }
Ejemplo n.º 3
0
 public Utf8Exception(Utf8ExceptionType type) : base(GetMessage(type))
 {
     this.type = type;
 }