Exemple #1
0
 public static IEnumerable <object[]> Parse_Invalid_TestData()
 {
     // Reuse all int test data, except for those that wouldn't overflow long.
     foreach (object[] objs in Int32Tests.Parse_Invalid_TestData())
     {
         if ((Type)objs[3] == typeof(OverflowException) &&
             (!BigInteger.TryParse((string)objs[0], out BigInteger bi) || (bi >= long.MinValue && bi <= long.MaxValue)))
         {
             continue;
         }
         yield return(objs);
     }
 }
Exemple #2
0
        public static IEnumerable <object[]> Parse_Invalid_TestData()
        {
            // Include the test data for wider primitives.
            foreach (object[] widerTests in Int32Tests.Parse_Invalid_TestData())
            {
                yield return(widerTests);
            }

            yield return(new object[] { "-129", NumberStyles.Integer, null, typeof(OverflowException) });       // < min value

            yield return(new object[] { "128", NumberStyles.Integer, null, typeof(OverflowException) });        // > max value

            yield return(new object[] { "FFFFFFFF", NumberStyles.HexNumber, null, typeof(OverflowException) }); // Hex number < 0

            yield return(new object[] { "100", NumberStyles.HexNumber, null, typeof(OverflowException) });      // Hex number > max value
        }
Exemple #3
0
        public static IEnumerable <object[]> Parse_Invalid_TestData()
        {
            // Reuse all Int32 test data, except for those that would be validating Int32 overflows,
            // since many of those will succeed for Int64.
            foreach (object[] objs in Int32Tests.Parse_Invalid_TestData())
            {
                if ((Type)objs[3] == typeof(OverflowException))
                {
                    continue;
                }
                yield return(objs);
            }

            // Then also validate Int64 boundary conditions for overflows.
            yield return(new object[] { "10000000000000000", NumberStyles.HexNumber, null, typeof(OverflowException) });

            yield return(new object[] { "-9223372036854775809", NumberStyles.Integer, null, typeof(OverflowException) });

            yield return(new object[] { "9223372036854775808", NumberStyles.Integer, null, typeof(OverflowException) });

            yield return(new object[] { "9223372036854775817", NumberStyles.Integer, null, typeof(OverflowException) });

            yield return(new object[] { "10000000000000000000", NumberStyles.Integer, null, typeof(OverflowException) });

            yield return(new object[] { "-10000000000000000000", NumberStyles.Integer, null, typeof(OverflowException) });

            yield return(new object[] { "922337203685477580a", NumberStyles.Integer, null, typeof(FormatException) });

            yield return(new object[] { "922337203685477580 a", NumberStyles.Integer, null, typeof(FormatException) });

            yield return(new object[] { "100000000000000000a", NumberStyles.Integer, null, typeof(FormatException) });

            yield return(new object[] { "1000000000000000000a", NumberStyles.Integer, null, typeof(FormatException) });

            yield return(new object[] { "100000000000000000 a", NumberStyles.Integer, null, typeof(FormatException) });

            yield return(new object[] { "1000000000000000000 a", NumberStyles.Integer, null, typeof(FormatException) });
        }
Exemple #4
0
        public static IEnumerable <object[]> Parse_Invalid_TestData()
        {
            // Reuse all int test data, except for those that wouldn't overflow uint.
            foreach (object[] objs in Int32Tests.Parse_Invalid_TestData())
            {
                if ((Type)objs[3] == typeof(OverflowException) &&
                    (!BigInteger.TryParse((string)objs[0], out BigInteger bi) || bi <= uint.MaxValue))
                {
                    continue;
                }

                yield return(objs);
            }

            // Then also validate UInt32 boundary conditions for overflows.
            foreach (string ws in new[] { "", "    " })
            {
                yield return(new object[] { ws + "-1" + ws, NumberStyles.Integer, null, typeof(OverflowException) });

                yield return(new object[] { ws + "abc123" + ws, NumberStyles.Integer, new NumberFormatInfo {
                                                NegativeSign = "abc"
                                            }, typeof(OverflowException) });
            }
        }