public static void ToString(double real, double imaginary)
{
var complex = new Complex(real, imaginary);
string expected = "(" + real.ToString() + ", " + imaginary.ToString() + ")";
string actual = complex.ToString();
Assert.Equal(expected, actual);
NumberFormatInfo numberFormatInfo = CultureInfo.CurrentCulture.NumberFormat;
expected = "(" + real.ToString(numberFormatInfo) + ", " + imaginary.ToString(numberFormatInfo) + ")";
actual = complex.ToString(numberFormatInfo);
Assert.Equal(expected, complex.ToString(numberFormatInfo));
foreach (string format in s_supportedStandardNumericFormats)
{
expected = "(" + real.ToString(format) + ", " + imaginary.ToString(format) + ")";
actual = complex.ToString(format);
Assert.Equal(expected, actual);
expected = "(" + real.ToString(format, numberFormatInfo) + ", " + imaginary.ToString(format, numberFormatInfo) + ")";
actual = complex.ToString(format, numberFormatInfo);
Assert.Equal(expected, actual);
}
}