You've already forked linux-packaging-mono
Imported Upstream version 4.2.0.179
Former-commit-id: 4610231f55806d2a05ed69e5ff3faa7336cc1479
This commit is contained in:
committed by
Jo Shields
parent
aa7da660d6
commit
c042cd0c52
@ -403,7 +403,7 @@ namespace MonoTests.System {
|
||||
Assert.AreEqual (typeof (int), Activator.CreateInstance (typeof (Nullable<int>), new object [] { null }).GetType ());
|
||||
Assert.AreEqual (null, Activator.CreateInstance (typeof (Nullable<int>)));
|
||||
}
|
||||
|
||||
#if FEATURE_REMOTING
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void GetObject_TypeNull ()
|
||||
@ -411,7 +411,6 @@ namespace MonoTests.System {
|
||||
Activator.GetObject (null, "tcp://localhost:1234/COMTestUri");
|
||||
}
|
||||
|
||||
#if !MOBILE
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentNullException))]
|
||||
public void GetObject_UrlNull ()
|
||||
@ -420,29 +419,10 @@ namespace MonoTests.System {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* This test is now executed in System.Runtime.Remoting unit tests
|
||||
[Test]
|
||||
public void GetObject ()
|
||||
{
|
||||
// This will provide a COMTest object on tcp://localhost:1234/COMTestUri
|
||||
COMTest objCOMTest = new COMTest (8);
|
||||
TcpChannel chnServer = new TcpChannel (1234);
|
||||
ChannelServices.RegisterChannel (chnServer);
|
||||
RemotingServices.SetObjectUriForMarshal (objCOMTest, "COMTestUri");
|
||||
RemotingServices.Marshal (objCOMTest);
|
||||
|
||||
// This will get the remoting object
|
||||
object objRem = Activator.GetObject (typeof (COMTest), "tcp://localhost:1234/COMTestUri");
|
||||
Assert.IsNotNull (objRem, "#A07");
|
||||
COMTest remCOMTest = (COMTest) objRem;
|
||||
Assert.AreEqual (8, remCOMTest.Id, "#A08");
|
||||
|
||||
ChannelServices.UnregisterChannel(chnServer);
|
||||
}
|
||||
*/
|
||||
// TODO: Implemente the test methods for all the overriden function using activationAttribute
|
||||
|
||||
[Test]
|
||||
[Category ("AndroidNotWorking")] // Assemblies aren't accessible using filesystem paths (they're either in apk, embedded in native code or not there at all
|
||||
public void CreateInstanceFrom ()
|
||||
{
|
||||
ObjectHandle objHandle = Activator.CreateInstanceFrom (testLocation, "MonoTests.System.ActivatorTestInternal.COMTest");
|
||||
@ -618,6 +598,16 @@ namespace MonoTests.System {
|
||||
Assert.AreEqual (42, a.A);
|
||||
Assert.AreEqual (null, a.X);
|
||||
Assert.AreEqual (null, a.Y);
|
||||
|
||||
var b = Activator.CreateInstance (typeof (SimpleParamsObjectConstructor), 1, 2, 3, 4, 5);
|
||||
Assert.IsNotNull (b);
|
||||
}
|
||||
|
||||
class SimpleParamsObjectConstructor
|
||||
{
|
||||
public SimpleParamsObjectConstructor (params object[] parameters)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class SimpleParamsConstructor {
|
||||
@ -656,5 +646,19 @@ namespace MonoTests.System {
|
||||
Assert.AreEqual (null, a.X);
|
||||
Assert.AreEqual (null, a.Y);
|
||||
}
|
||||
|
||||
class ParamsConstructorWithObjectConversion
|
||||
{
|
||||
public ParamsConstructorWithObjectConversion (params int[] x)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CreateInstanceParamsConstructorWithObjectConversion ()
|
||||
{
|
||||
var a = Activator.CreateInstance (typeof(ParamsConstructorWithObjectConversion), new object[] { (object) 2 });
|
||||
Assert.IsNotNull (a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
a9eb1d3c5c0f2e553f7dec495c3836af1f09d565
|
||||
03de187af3d953521b3b78452e6eff523b6be07a
|
@ -828,6 +828,22 @@ namespace MonoTests.System
|
||||
Assert.IsFalse (Attribute.IsDefined (typeof (AttributeTest), typeof(SerializableAttribute), true), "#2");
|
||||
}
|
||||
|
||||
[YourCustomAttribute (0)]
|
||||
[Serializable]
|
||||
[MyCustomAttribute ("")]
|
||||
class ClassForOrderIsImportant
|
||||
{
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OrderIsImportant ()
|
||||
{
|
||||
var custom = typeof (ClassForOrderIsImportant).GetCustomAttributes (false);
|
||||
Assert.IsTrue (custom [0].GetType () == typeof (YourCustomAttribute));
|
||||
Assert.IsTrue (custom [1].GetType () == typeof (MyCustomAttribute));
|
||||
Assert.IsTrue (custom [2].GetType () == typeof (SerializableAttribute));
|
||||
}
|
||||
|
||||
#if !MONOTOUCH
|
||||
[Test]
|
||||
public void GetCustomAttributeOnNewSreTypes ()
|
||||
@ -1013,6 +1029,25 @@ namespace MonoTests.System
|
||||
AttributeWithTypeId a = new AttributeWithTypeId ();
|
||||
a.GetHashCode ();
|
||||
}
|
||||
|
||||
class ArrayAttribute : Attribute
|
||||
{
|
||||
#pragma warning disable 414
|
||||
int[] array;
|
||||
#pragma warning restore
|
||||
|
||||
public ArrayAttribute (int[] array)
|
||||
{
|
||||
this.array = array;
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ArrayFieldsEquality ()
|
||||
{
|
||||
Assert.IsTrue (new ArrayAttribute (new int[] { 1, 2 }).Equals (new ArrayAttribute (new int[] { 1, 2 })));
|
||||
Assert.IsFalse (new ArrayAttribute (new int[] { 1, 2 }).Equals (new ArrayAttribute (new int[] { 1, 1 })));
|
||||
}
|
||||
}
|
||||
|
||||
namespace ParamNamespace {
|
||||
@ -1050,6 +1085,12 @@ namespace MonoTests.System
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
class Multiple {
|
||||
public void Bar ([Foo] [Bar] string multiple, [Bar] string bar)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
@ -1142,6 +1183,24 @@ namespace MonoTests.System
|
||||
Assert.AreEqual ("Derived.baz", attributes [0].Data);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleParameterAttributes ()
|
||||
{
|
||||
var parameter = GetParameter (typeof(ParamNamespace.Multiple), "Bar", "multiple");
|
||||
var foo = parameter.GetCustomAttribute<ParamNamespace.FooAttribute> ();
|
||||
Assert.AreEqual (typeof(ParamNamespace.FooAttribute), foo.GetType ());
|
||||
var bar = parameter.GetCustomAttribute<ParamNamespace.BarAttribute> ();
|
||||
Assert.AreEqual (typeof(ParamNamespace.BarAttribute), bar.GetType ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MultipleParameterAttributes2 ()
|
||||
{
|
||||
var parameter = GetParameter (typeof(ParamNamespace.Multiple), "Bar", "bar");
|
||||
var foo = parameter.GetCustomAttribute<ParamNamespace.FooAttribute> ();
|
||||
Assert.IsNull (foo);
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Event | AttributeTargets.Method | AttributeTargets.Class)]
|
||||
public class MyCAttr : Attribute {}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
c97a0a31b7e8efef77818a2016c941aecbb73fcb
|
||||
f9dc5929d3107412fcd6141a8da70093abad780d
|
@ -1069,6 +1069,27 @@ namespace MonoTests.System
|
||||
action_int (42);
|
||||
}
|
||||
|
||||
struct FooStruct {
|
||||
public int i, j, k, l;
|
||||
|
||||
public int GetProp (int a, int b, int c, int d) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
delegate int ByRefDelegate (ref FooStruct s, int a, int b, int c, int d);
|
||||
|
||||
#if MONOTOUCH
|
||||
[Category ("NotWorking")]
|
||||
#endif
|
||||
[Test]
|
||||
public void CallVirtVType ()
|
||||
{
|
||||
var action = (ByRefDelegate)Delegate.CreateDelegate (typeof (ByRefDelegate), null, typeof (FooStruct).GetMethod ("GetProp"));
|
||||
var s = new FooStruct () { i = 42 };
|
||||
Assert.AreEqual (42, action (ref s, 1, 2, 3, 4));
|
||||
}
|
||||
|
||||
class Foo {
|
||||
|
||||
public void Bar ()
|
||||
|
@ -201,22 +201,22 @@ namespace MonoTests.System
|
||||
|
||||
Assert.AreEqual ("00", TestingEnum4.This.ToString ("x"), "#B1");
|
||||
Assert.AreEqual ("00", TestingEnum4.This.ToString ("X"), "#B2");
|
||||
Assert.AreEqual ("ff", TestingEnum4.Test.ToString ("x"), "#B3");
|
||||
Assert.AreEqual ("FF", TestingEnum4.Test.ToString ("x"), "#B3");
|
||||
Assert.AreEqual ("FF", TestingEnum4.Test.ToString ("X"), "#B4");
|
||||
|
||||
Assert.AreEqual ("0000", TestingEnum5.This.ToString ("x"), "#C1");
|
||||
Assert.AreEqual ("0000", TestingEnum5.This.ToString ("X"), "#C2");
|
||||
Assert.AreEqual ("7fff", TestingEnum5.Test.ToString ("x"), "#C3");
|
||||
Assert.AreEqual ("7FFF", TestingEnum5.Test.ToString ("x"), "#C3");
|
||||
Assert.AreEqual ("7FFF", TestingEnum5.Test.ToString ("X"), "#C4");
|
||||
|
||||
Assert.AreEqual ("00000000", TestingEnum6.This.ToString ("x"), "#D1");
|
||||
Assert.AreEqual ("00000000", TestingEnum6.This.ToString ("X"), "#D2");
|
||||
Assert.AreEqual ("7fffffff", TestingEnum6.Test.ToString ("x"), "#D3");
|
||||
Assert.AreEqual ("7FFFFFFF", TestingEnum6.Test.ToString ("x"), "#D3");
|
||||
Assert.AreEqual ("7FFFFFFF", TestingEnum6.Test.ToString ("X"), "#D4");
|
||||
|
||||
Assert.AreEqual ("0000000000000000", TestingEnum3.This.ToString ("x"), "#E1");
|
||||
Assert.AreEqual ("0000000000000000", TestingEnum3.This.ToString ("X"), "#E2");
|
||||
Assert.AreEqual ("ffffffffffffffff", TestingEnum3.Test.ToString ("x"), "#E3");
|
||||
Assert.AreEqual ("FFFFFFFFFFFFFFFF", TestingEnum3.Test.ToString ("x"), "#E3");
|
||||
Assert.AreEqual ("FFFFFFFFFFFFFFFF", TestingEnum3.Test.ToString ("X"), "#E4");
|
||||
}
|
||||
|
||||
|
@ -479,13 +479,24 @@ namespace MonoTests.System
|
||||
[Test]
|
||||
public void TestPow ()
|
||||
{
|
||||
double precision;
|
||||
int iTest = 1;
|
||||
|
||||
#if MONODROID
|
||||
// It fails on Nexus 9 with
|
||||
//
|
||||
// 1.3636094460602122 != 1.3636094460602119
|
||||
//
|
||||
// when using double_epsilon. Precision differs between different ARM CPUs, so we
|
||||
// will just use a more conservative value
|
||||
precision = 0.000001;
|
||||
#else
|
||||
precision = double_epsilon;
|
||||
#endif
|
||||
try {
|
||||
double a = Math.Pow (y, x);
|
||||
double b = 1.363609446060212;
|
||||
|
||||
Assert.IsTrue ((Math.Abs (a - b) <= double_epsilon), a.ToString ("G99") + " != " + b.ToString ("G99"));
|
||||
Assert.IsTrue ((Math.Abs (a - b) <= precision), a.ToString ("G99") + " != " + b.ToString ("G99"));
|
||||
iTest++;
|
||||
Assert.IsTrue (double.IsNaN (Math.Pow (y, double.NaN)));
|
||||
iTest++;
|
||||
|
@ -1 +1 @@
|
||||
76643d858f9403b33d309fb960ee61314fb64fd7
|
||||
74570292985d0e3c02e90e5d03a21dd4521dbb03
|
@ -55,16 +55,17 @@ namespace MonoTests.System
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))]
|
||||
public void EndBeforeStart ()
|
||||
{
|
||||
if (Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
throw new ArgumentOutOfRangeException ();;
|
||||
DateTime dateStart = new DateTime (2007,01,01);
|
||||
DateTime dateEnd = new DateTime (2006,01,01);
|
||||
TimeZoneInfo.TransitionTime daylightTransitionStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 03, 11);
|
||||
TimeZoneInfo.TransitionTime daylightTransitionEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 10, 11);
|
||||
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (dateStart, dateEnd, new TimeSpan (1,0,0), daylightTransitionStart, daylightTransitionEnd);
|
||||
try {
|
||||
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (dateStart, dateEnd, new TimeSpan (1,0,0), daylightTransitionStart, daylightTransitionEnd);
|
||||
Assert.Fail ();
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -79,7 +80,6 @@ namespace MonoTests.System
|
||||
}
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentOutOfRangeException))]
|
||||
public void DeltaNotInSeconds ()
|
||||
{
|
||||
if (Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
@ -88,7 +88,11 @@ namespace MonoTests.System
|
||||
DateTime dateEnd = new DateTime (2008,01,01);
|
||||
TimeZoneInfo.TransitionTime daylightTransitionStart = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 03, 11);
|
||||
TimeZoneInfo.TransitionTime daylightTransitionEnd = TimeZoneInfo.TransitionTime.CreateFixedDateRule (new DateTime (1,1,1,2,0,0), 10, 11);
|
||||
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (dateStart, dateEnd, new TimeSpan (55), daylightTransitionStart, daylightTransitionEnd);
|
||||
try {
|
||||
TimeZoneInfo.AdjustmentRule.CreateAdjustmentRule (dateStart, dateEnd, new TimeSpan (55), daylightTransitionStart, daylightTransitionEnd);
|
||||
Assert.Fail ();
|
||||
} catch (ArgumentException) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,8 @@ using System;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using System.Collections;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
|
||||
using NUnit.Framework;
|
||||
namespace MonoTests.System
|
||||
@ -664,6 +666,12 @@ namespace MonoTests.System
|
||||
[TestFixture]
|
||||
public class GetSystemTimeZonesTests
|
||||
{
|
||||
[Test]
|
||||
public void Identity ()
|
||||
{
|
||||
Assert.AreSame (TimeZoneInfo.GetSystemTimeZones (), TimeZoneInfo.GetSystemTimeZones ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void NotEmpty ()
|
||||
{
|
||||
@ -802,6 +810,32 @@ namespace MonoTests.System
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
public void SubminuteDSTOffsets ()
|
||||
{
|
||||
if (Environment.OSVersion.Platform != PlatformID.Unix)
|
||||
Assert.Ignore ();
|
||||
|
||||
var subMinuteDSTs = new string [] {
|
||||
"Europe/Dublin", // Europe/Dublin has a DST offset of 34 minutes and 39 seconds in 1916.
|
||||
"Europe/Amsterdam",
|
||||
"America/St_Johns",
|
||||
"Canada/Newfoundland",
|
||||
"Europe/Moscow",
|
||||
"Europe/Riga",
|
||||
"N/A", // testing that the test doesn't fail with inexistent TZs
|
||||
};
|
||||
foreach (var tz in subMinuteDSTs) {
|
||||
try {
|
||||
TimeZoneInfo.FindSystemTimeZoneById (tz);
|
||||
} catch (TimeZoneNotFoundException) {
|
||||
// ok;
|
||||
} catch (Exception ex) {
|
||||
Assert.Fail (string.Format ("Failed to load TZ {0}: {1}", tz, ex.ToString ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
@ -1000,5 +1034,34 @@ namespace MonoTests.System
|
||||
Assert.AreEqual(baseUtcOffset, cairo.GetUtcOffset (d.Add (new TimeSpan(0,0,0, 1))));
|
||||
}
|
||||
}
|
||||
|
||||
[TestFixture]
|
||||
public class GetDaylightChanges
|
||||
{
|
||||
MethodInfo getChanges;
|
||||
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
|
||||
getChanges = typeof (TimeZoneInfo).GetMethod ("GetDaylightChanges", flags);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSydneyDaylightChanges ()
|
||||
{
|
||||
TimeZoneInfo tz;
|
||||
if (Environment.OSVersion.Platform == PlatformID.Unix)
|
||||
tz = TimeZoneInfo.FindSystemTimeZoneById ("Australia/Sydney");
|
||||
else
|
||||
tz = TimeZoneInfo.FindSystemTimeZoneById ("W. Australia Standard Time");
|
||||
|
||||
var changes = (DaylightTime) getChanges.Invoke (tz, new object [] {2014});
|
||||
|
||||
Assert.AreEqual (new TimeSpan (1, 0, 0), changes.Delta);
|
||||
Assert.AreEqual (new DateTime (2014, 10, 5, 2, 0, 0), changes.Start);
|
||||
Assert.AreEqual (new DateTime (2014, 4, 6, 3, 0, 0), changes.End);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,13 +27,13 @@ public class TimeZoneTest {
|
||||
Assert.AreEqual("CEST", t1.DaylightName, "A02");
|
||||
|
||||
DaylightTime d1 = t1.GetDaylightChanges (2002);
|
||||
Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G"), "A03");
|
||||
Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G"), "A04");
|
||||
Assert.AreEqual("03/31/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "A03");
|
||||
Assert.AreEqual("10/27/2002 03:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "A04");
|
||||
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "A05");
|
||||
|
||||
DaylightTime d2 = t1.GetDaylightChanges (1996);
|
||||
Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G"), "A06");
|
||||
Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G"), "A07");
|
||||
Assert.AreEqual("03/31/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "A06");
|
||||
Assert.AreEqual("10/27/1996 03:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "A07");
|
||||
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "A08");
|
||||
|
||||
DateTime d3 = new DateTime (2002,2,25);
|
||||
@ -46,6 +46,11 @@ public class TimeZoneTest {
|
||||
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d3).Ticks, "A12");
|
||||
Assert.AreEqual(72000000000L, t1.GetUtcOffset (d4).Ticks, "A13");
|
||||
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d5).Ticks, "A14");
|
||||
|
||||
// Test TimeZone methods with UTC DateTime in DST.
|
||||
DateTime d6 = d4.ToUniversalTime ();
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "A15");
|
||||
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "A16");
|
||||
}
|
||||
|
||||
private void EST (TimeZone t1)
|
||||
@ -55,25 +60,31 @@ public class TimeZoneTest {
|
||||
//Assert.AreEqual("Eastern Daylight Time", t1.DaylightName, "B02");
|
||||
|
||||
DaylightTime d1 = t1.GetDaylightChanges (2002);
|
||||
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G"), "B03");
|
||||
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "B04");
|
||||
Assert.AreEqual("04/07/2002 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "B03");
|
||||
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "B04");
|
||||
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "B05");
|
||||
|
||||
DaylightTime d2 = t1.GetDaylightChanges (1996);
|
||||
Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G"), "B06");
|
||||
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "B07");
|
||||
Assert.AreEqual("04/07/1996 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "B06");
|
||||
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "B07");
|
||||
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "B08");
|
||||
|
||||
DateTime d3 = new DateTime (2002,2,25);
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d3), "B09");
|
||||
DateTime d4 = new DateTime (2002,4,8);
|
||||
Assert.AreEqual(true, t1.IsDaylightSavingTime (d4), "B10");
|
||||
|
||||
DateTime d5 = new DateTime (2002,11,4);
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d5), "B11");
|
||||
|
||||
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d3).Ticks, "B12");
|
||||
Assert.AreEqual(-144000000000L, t1.GetUtcOffset (d4).Ticks, "B13");
|
||||
Assert.AreEqual(-180000000000L, t1.GetUtcOffset (d5).Ticks, "B14");
|
||||
|
||||
// Test TimeZone methods with UTC DateTime in DST.
|
||||
DateTime d6 = d4.ToUniversalTime ();
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "B15");
|
||||
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "B16");
|
||||
}
|
||||
|
||||
private void TST (TimeZone t1)
|
||||
@ -101,13 +112,13 @@ public class TimeZoneTest {
|
||||
Assert.IsTrue("BST" == t1.DaylightName || "IST" == t1.DaylightName, "D02");
|
||||
|
||||
DaylightTime d1 = t1.GetDaylightChanges (2002);
|
||||
Assert.AreEqual("03/31/2002 01:00:00", d1.Start.ToString ("G"), "D03");
|
||||
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G"), "D04");
|
||||
Assert.AreEqual("03/31/2002 01:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "D03");
|
||||
Assert.AreEqual("10/27/2002 02:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "D04");
|
||||
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "D05");
|
||||
|
||||
DaylightTime d2 = t1.GetDaylightChanges (1996);
|
||||
Assert.AreEqual("03/31/1996 01:00:00", d2.Start.ToString ("G"), "D06");
|
||||
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G"), "D07");
|
||||
Assert.AreEqual("03/31/1996 01:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "D06");
|
||||
Assert.AreEqual("10/27/1996 02:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "D07");
|
||||
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "D08");
|
||||
|
||||
DateTime d3 = new DateTime (2002,2,25);
|
||||
@ -120,6 +131,11 @@ public class TimeZoneTest {
|
||||
Assert.AreEqual(0L, t1.GetUtcOffset (d3).Ticks, "D12");
|
||||
Assert.AreEqual(36000000000L, t1.GetUtcOffset (d4).Ticks, "D13");
|
||||
Assert.AreEqual(0L, t1.GetUtcOffset (d5).Ticks, "D14");
|
||||
|
||||
// Test TimeZone methods with UTC DateTime in DST.
|
||||
DateTime d6 = d4.ToUniversalTime ();
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "D15");
|
||||
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "D16");
|
||||
}
|
||||
|
||||
private void NZST(TimeZone t1) {
|
||||
@ -127,13 +143,13 @@ public class TimeZoneTest {
|
||||
Assert.AreEqual("NZDT", t1.DaylightName, "E02");
|
||||
|
||||
DaylightTime d1 = t1.GetDaylightChanges (2013);
|
||||
Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G"), "E03");
|
||||
Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G"), "E04");
|
||||
Assert.AreEqual("09/29/2013 02:00:00", d1.Start.ToString ("G", CultureInfo.InvariantCulture), "E03");
|
||||
Assert.AreEqual("04/07/2013 03:00:00", d1.End.ToString ("G", CultureInfo.InvariantCulture), "E04");
|
||||
Assert.AreEqual(36000000000L, d1.Delta.Ticks, "E05");
|
||||
|
||||
DaylightTime d2 = t1.GetDaylightChanges (2001);
|
||||
Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G"), "E06");
|
||||
Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G"), "E07");
|
||||
Assert.AreEqual("10/07/2001 02:00:00", d2.Start.ToString ("G", CultureInfo.InvariantCulture), "E06");
|
||||
Assert.AreEqual("03/18/2001 03:00:00", d2.End.ToString ("G", CultureInfo.InvariantCulture), "E07");
|
||||
Assert.AreEqual(36000000000L, d2.Delta.Ticks, "E08");
|
||||
|
||||
DateTime d3 = new DateTime(2013,02,15);
|
||||
@ -146,10 +162,14 @@ public class TimeZoneTest {
|
||||
Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d3).Ticks, "E12");
|
||||
Assert.AreEqual(36000000000L /*hour*/ * 12L, t1.GetUtcOffset (d4).Ticks, "E13");
|
||||
Assert.AreEqual(36000000000L /*hour*/ * 13L, t1.GetUtcOffset (d5).Ticks, "E14");
|
||||
|
||||
// Test TimeZone methods with UTC DateTime in DST.
|
||||
DateTime d6 = d5.ToUniversalTime ();
|
||||
Assert.AreEqual(false, t1.IsDaylightSavingTime (d6), "E15");
|
||||
Assert.AreEqual(0, t1.GetUtcOffset (d6).Ticks, "E16");
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Culture ("")]
|
||||
public void TestCtors ()
|
||||
{
|
||||
TimeZone t1 = TimeZone.CurrentTimeZone;
|
||||
|
@ -1 +1 @@
|
||||
94fe67d34ab12960a9683d4b9da0e17fa5d7264c
|
||||
9f87bcd74d19a29f1b4e41b2d7171f2c1af2835c
|
70
mcs/class/corlib/Test/System/TypedReferenceTest.cs
Normal file
70
mcs/class/corlib/Test/System/TypedReferenceTest.cs
Normal file
@ -0,0 +1,70 @@
|
||||
//
|
||||
// TypedReferenceTest.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTests.System
|
||||
{
|
||||
#if !MONODROID // Type load segfaults the runtime on ARM64 (https://gist.github.com/grendello/334d06c45376602a9afc)
|
||||
[TestFixture]
|
||||
public class TypedReferenceTest
|
||||
{
|
||||
struct TestFields
|
||||
{
|
||||
public int MaxValue;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetTargetType ()
|
||||
{
|
||||
TestFields fields = new TestFields { MaxValue = 1234 };
|
||||
|
||||
TypedReference ti = __makeref(fields);
|
||||
Assert.AreEqual (typeof (TestFields), TypedReference.GetTargetType (ti));
|
||||
}
|
||||
|
||||
struct AStruct {
|
||||
public string b;
|
||||
}
|
||||
|
||||
class CClass {
|
||||
public AStruct a;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void MakeTypedReference ()
|
||||
{
|
||||
var o = new CClass () { a = new AStruct () { b = "5" }};
|
||||
TypedReference r = TypedReference.MakeTypedReference (o, new FieldInfo[] { typeof (CClass).GetField ("a"), typeof (AStruct).GetField ("b") });
|
||||
Assert.AreEqual ("5", TypedReference.ToObject (r));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user