Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@@ -1 +1 @@
8772d7afdea04e8771c54266715144cacfffa015
0836640057e3cfabdb47c8cc3ab4990f87869cad

View File

@@ -705,6 +705,23 @@ namespace MonoTests.System {
expected = string.Format ("{0:D2}/{1:D2}/{2} 00:00:45 +00:00", now.Month, now.Day, now.Year);
Assert.AreEqual (expected, date.ToString (CultureInfo.InvariantCulture));
}
[Test]
public void TestDateOnlyWithTimeOffset ()
{
var fp = CultureInfo.InvariantCulture;
var date = DateTimeOffset.Parse("2013-11-07+11:00", fp, DateTimeStyles.AssumeUniversal);
var expected = string.Format ("{0:D2}/{1:D2}/{2} 00:00:00 +11:00", 11, 7, 2013);
Assert.AreEqual (expected, date.ToString (CultureInfo.InvariantCulture));
}
[Test]
public void GMTDateTime ()
{
var date = DateTimeOffset.Parse ("Wed, 10 Sep 2014 22:01:40 GMT", CultureInfo.InvariantCulture);
var expected = "09/10/2014 22:01:40 +00:00";
Assert.AreEqual (expected, date.ToString (CultureInfo.InvariantCulture));
}
}
}

View File

@@ -2584,5 +2584,40 @@ namespace MonoTests.System
Assert.AreEqual (dt, parsed, "#1");
}
[Test]
public void ISO8601FractionalDigits ()
{
string date = "2014-08-25T01:20:23.601911612343423423465789789365674575676746756747467Z";
long expectedTicks = 635445264236019116;
var dt = DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
Assert.AreEqual (expectedTicks, dt.Ticks);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ISO8601FractionalDigitsException1 ()
{
string date = "2014-08-25T01:20:23.60191161234342342346578978936567457567:6746756747467Z";
DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ISO8601FractionalDigitsException2 ()
{
string date = "2014-08-25T01:20:23.6019116-12343423423465789789365674575676746756747467Z";
DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
}
[Test]
[ExpectedException (typeof (FormatException))]
public void ISO8601FractionalDigitsException3 ()
{
string date = "2014-08-25T01:20:23.601911612343423423465789789365674575676746756747467%Z";
DateTime.Parse (date, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);
}
}
}

View File

@@ -24,12 +24,15 @@ public class SByteTest
private const string MyString3 = "127";
private string[] Formats1 = {"c", "d", "e", "f", "g", "n", "p", "x" };
private string[] Formats2 = {"c5", "d5", "e5", "f5", "g5", "n5", "p5", "x5" };
#if false
// These are not currently being tested against, due to the locale-specific nature of the test, we need a different way of doing this
private string[] Results1 = {"("+NumberFormatInfo.CurrentInfo.CurrencySymbol+"128.00)",
"-128", "-1.280000e+002", "-128.00",
"-128", "-128.00", "-12,800.00 %", "80"};
private string[] Results2 = {NumberFormatInfo.CurrentInfo.CurrencySymbol+"127.00000",
"00127", "1.27000e+002", "127.00000",
"127", "127.00000", "12,700.00000 %", "0007f"};
#endif
private string[] ResultsNfi1 = {"("+NumberFormatInfo.InvariantInfo.CurrencySymbol+"128.00)",
"-128", "-1.280000e+002", "-128.00",
"-128", "-128.00", "-12,800.00 %", "80"};
@@ -161,14 +164,17 @@ public class SByteTest
Assert.IsTrue(String.Compare(MyString2, MySByte2.ToString()) == 0, "MyString2, MySByte2.ToString()");
Assert.IsTrue(String.Compare(MyString3, MySByte3.ToString()) == 0, "MyString3, MySByte3.ToString()");
//test ToString(string format)
#if false
/*
TODO: These tests depend on the culture of the system running the test.
So, this needs to be tested in a different way.
* TODO: These tests depend on the culture of the system running the test.
* So, this needs to be tested in a different way.
/
for (int i=0; i < Formats1.Length; i++) {
Assert.IsTrue("i="+i+", Results1[i]="+Results1[i]+", MySByte2.ToString(Formats1[i])="+MySByte2.ToString(Formats1[i]), String.Compare(Results1[i], MySByte2.ToString(Formats1[i])) == 0);
Assert.IsTrue(String.Compare(Results2[i], MySByte3.ToString(Formats2[i])) == 0, "Results2[i], MySByte3.ToString(Formats2[i])");
}
*/
#endif
//test ToString(string format, IFormatProvider provider);
for (int i=0; i < Formats1.Length; i++) {
Assert.IsTrue(String.Compare(ResultsNfi1[i], MySByte2.ToString(Formats1[i], Nfi)) == 0, "i="+i+", ResultsNfi1[i]="+ResultsNfi1[i]+", MySByte2.ToString(Formats1[i]="+Formats1[i]+"): Expected "+ResultsNfi1[i]+" but got "+MySByte2.ToString(Formats1[i], Nfi));

View File

@@ -1430,6 +1430,18 @@ public class TimeSpanTest {
ts = new TimeSpan (123456789);
Assert.AreEqual ("12.3", ts.ToString ("s\\.f"), "#F0");
Assert.AreEqual ("12.3", ts.ToString ("s\\.F"), "#F1");
Assert.AreEqual ("12.3456789", ts.ToString ("s\\.fffffff"), "#F2");
Assert.AreEqual ("12.345678", ts.ToString ("s\\.ffffff"), "#F3");
ts = new TimeSpan (1234);
Assert.AreEqual ("0.000123", ts.ToString ("s\\.ffffff"), "#G0");
Assert.AreEqual ("0.0001", ts.ToString ("s\\.ffff"), "#G1");
Assert.AreEqual ("0.", ts.ToString ("s\\.F"), "#G2");
Assert.AreEqual ("0.", ts.ToString ("s\\.FFF"), "#G3");
ts = TimeSpan.FromSeconds (0.05);
Assert.AreEqual (".0", ts.ToString ("\\.f"), "#H0");
Assert.AreEqual (".", ts.ToString ("\\.F"), "#H1");
}
[Test]

View File

@@ -303,11 +303,12 @@ public class TimeZoneTest {
TimeZone tz = TimeZone.CurrentTimeZone;
DaylightTime daylightChanges = tz.GetDaylightChanges(2007);
int year = DateTime.Now.Year;
DaylightTime daylightChanges = tz.GetDaylightChanges(year);
DateTime dst_end = daylightChanges.End;
if (dst_end == DateTime.MinValue)
Assert.Ignore (tz.StandardName + " did not observe daylight saving time during 2007.");
Assert.Ignore (tz.StandardName + " did not observe daylight saving time during " + year + ".");
var standardOffset = tz.GetUtcOffset(daylightChanges.Start.AddMinutes(-1));

View File

@@ -1 +1 @@
00131c8d47f1d59ef4266e335ec71b293424a720
6acbac2dd9f4343e294871c32192c68a76bef31b