public static IEnumerable <object[]> Parse_Valid_TestData() { // Reuse all Int64 test data foreach (object[] objs in Int64Tests.Parse_Valid_TestData()) { bool unsigned = (((NumberStyles)objs[1]) & NumberStyles.HexNumber) == NumberStyles.HexNumber; yield return(new object[] { objs[0], objs[1], objs[2], unsigned ? (Int128)(ulong)(long)objs[3] : (Int128)(long)objs[3] }); } // All lengths decimal foreach (bool neg in new[] { false, true }) { string s = neg ? "-" : ""; Int128 result = 0; for (int i = 1; i <= 19; i++) { result = (result * 10) + (i % 10); s += (i % 10).ToString(); yield return(new object[] { s, NumberStyles.Integer, null, neg ? result * -1 : result }); } } // All lengths hexadecimal { string s = ""; Int128 result = 0; for (int i = 1; i <= 16; i++) { result = (result * 16) + (i % 16); s += (i % 16).ToString("X"); yield return(new object[] { s, NumberStyles.HexNumber, null, result }); } } // And test boundary conditions for Int128 yield return(new object[] { "-170141183460469231731687303715884105728", NumberStyles.Integer, null, Int128.MinValue }); yield return(new object[] { "170141183460469231731687303715884105727", NumberStyles.Integer, null, Int128.MaxValue }); yield return(new object[] { " -170141183460469231731687303715884105728 ", NumberStyles.Integer, null, Int128.MinValue }); yield return(new object[] { " +170141183460469231731687303715884105727 ", NumberStyles.Integer, null, Int128.MaxValue }); yield return(new object[] { "7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", NumberStyles.HexNumber, null, Int128.MaxValue }); yield return(new object[] { "80000000000000000000000000000000", NumberStyles.HexNumber, null, Int128.MinValue }); yield return(new object[] { "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", NumberStyles.HexNumber, null, (Int128)(-1) }); yield return(new object[] { " FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ", NumberStyles.HexNumber, null, (Int128)(-1) }); }
public static IEnumerable <object[]> Parse_Valid_TestData() { // Reuse all Int64 test data that's relevant foreach (object[] objs in Int64Tests.Parse_Valid_TestData()) { if ((long)objs[3] < 0) { continue; } yield return(new object[] { objs[0], objs[1], objs[2], (ulong)(long)objs[3] }); } // All lengths decimal { string s = ""; ulong result = 0; for (int i = 1; i <= 20; i++) { result = (result * 10) + (ulong)(i % 10); s += (i % 10).ToString(); yield return(new object[] { s, NumberStyles.Integer, null, result }); } } // All lengths hexadecimal { string s = ""; ulong result = 0; for (int i = 1; i <= 16; i++) { result = (result * 16) + (ulong)(i % 16); s += (i % 16).ToString("X"); yield return(new object[] { s, NumberStyles.HexNumber, null, result }); } } // And test boundary conditions for UInt64 yield return(new object[] { "18446744073709551615", NumberStyles.Integer, null, ulong.MaxValue }); yield return(new object[] { "+18446744073709551615", NumberStyles.Integer, null, ulong.MaxValue }); yield return(new object[] { " +18446744073709551615 ", NumberStyles.Integer, null, ulong.MaxValue }); yield return(new object[] { "FFFFFFFFFFFFFFFF", NumberStyles.HexNumber, null, ulong.MaxValue }); yield return(new object[] { " FFFFFFFFFFFFFFFF ", NumberStyles.HexNumber, null, ulong.MaxValue }); }