2002-09-21 Zoltan Varga <vargaz@freemail.hu>
authorPaolo Molaro <lupus@oddwiz.org>
Tue, 24 Sep 2002 09:09:35 +0000 (09:09 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Tue, 24 Sep 2002 09:09:35 +0000 (09:09 -0000)
* AllTests.cs: new file

* RuntimeHelpersTest.cs: new file

svn path=/trunk/mcs/; revision=7760

mcs/class/corlib/Test/System.Runtime.CompilerServices/AllTests.cs [new file with mode: 0644]
mcs/class/corlib/Test/System.Runtime.CompilerServices/ChangeLog [new file with mode: 0644]
mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs [new file with mode: 0644]

diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/AllTests.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/AllTests.cs
new file mode 100644 (file)
index 0000000..81f960a
--- /dev/null
@@ -0,0 +1,29 @@
+// Testsuite.System.AllSystemTests.cs
+//
+// Mario Martinez (mariom925@home.om)
+//
+// (C) Ximian, Inc.  http://www.ximian.com
+// 
+
+using System;
+using NUnit.Framework;
+
+namespace MonoTests.System.Runtime.CompilerServices {
+        /// <summary>
+        ///   Combines all available unit tests into one test suite.
+        /// </summary>
+        public class AllTests : TestCase {
+                public AllTests(string name) : base(name) {}
+                
+                public static ITest Suite 
+                { 
+                        get 
+                        {
+                                TestSuite suite =  new TestSuite();
+                                suite.AddTest(RuntimeHelpersTest.Suite);
+                                return suite;
+                        }
+                }
+        }
+}
+
diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/ChangeLog b/mcs/class/corlib/Test/System.Runtime.CompilerServices/ChangeLog
new file mode 100644 (file)
index 0000000..c2a389d
--- /dev/null
@@ -0,0 +1,6 @@
+2002-09-21  Zoltan Varga  <vargaz@freemail.hu>
+
+       * AllTests.cs: new file
+
+       * RuntimeHelpersTest.cs: new file
+
diff --git a/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs b/mcs/class/corlib/Test/System.Runtime.CompilerServices/RuntimeHelpersTest.cs
new file mode 100644 (file)
index 0000000..ca9c01b
--- /dev/null
@@ -0,0 +1,86 @@
+//\r
+// RuntimeHelpersTest.cs - NUnit Test Cases for the System.Runtime.CompilerServices.RuntimeHelpers class\r
+//\r
+// Zoltan Varga (vargaz@freemail.hu)\r
+//\r
+// (C) Ximian, Inc.  http://www.ximian.com\r
+\r
+using System;\r
+using System.Runtime.CompilerServices;\r
+\r
+using NUnit.Framework;\r
+\r
+namespace MonoTests.System.Runtime.CompilerServices {\r
+\r
+       public class RuntimeHelpersTest : TestCase {\r
+           struct FooStruct {\r
+                       public int i;\r
+                       public string j;\r
+               }\r
+\r
+               class FooClass {\r
+                       public static int counter = 0;\r
+\r
+                       static FooClass () {\r
+                               counter = counter + 1;\r
+                       }\r
+               }\r
+\r
+               public RuntimeHelpersTest () : base ("MonoTests.System.Runtime.CompilerServices.RuntimeHelpers testcase") {}\r
+\r
+               public RuntimeHelpersTest (String name) : base (name) {}\r
+         \r
+               protected override void SetUp ()\r
+               {\r
+               }\r
+\r
+               public static ITest Suite\r
+               {\r
+                       get {\r
+                               return new TestSuite(typeof(RuntimeHelpersTest));\r
+                       }\r
+               }\r
+\r
+               public void TestOffsetToStringData () \r
+               {\r
+                       AssertEquals ("OffsetToStringData is not constant",\r
+                                                 RuntimeHelpers.OffsetToStringData,\r
+                                                 RuntimeHelpers.OffsetToStringData);\r
+               }\r
+\r
+               public void TestGetObjectValue ()\r
+               {\r
+                       FooStruct s1;\r
+                       FooStruct s2;\r
+\r
+                       // Test null\r
+                       AssertEquals ("",\r
+                                                 RuntimeHelpers.GetObjectValue (null),\r
+                                                 null);\r
+                       \r
+                       // Test non-valuetype\r
+                       AssertEquals ("",\r
+                                                 RuntimeHelpers.GetObjectValue (this),\r
+                                                 this);\r
+\r
+                       // Test valuetype\r
+                       s1.i = 42;\r
+                       s1.j = "FOO";\r
+                       s2 = (FooStruct)RuntimeHelpers.GetObjectValue(s1);\r
+                       s1.i = 43;\r
+                       s1.j = "BAR";\r
+                       AssertEquals ("", s2.i, 42);\r
+                       AssertEquals ("", s2.j, "FOO");\r
+               }\r
+\r
+               public void TestRunClassConstructor ()\r
+               {\r
+                       RuntimeHelpers.RunClassConstructor (typeof(FooClass).TypeHandle);\r
+                       AssertEquals ("", FooClass.counter, 1);\r
+\r
+                       // Each static constructor should only be run once\r
+                       RuntimeHelpers.RunClassConstructor (typeof(FooClass).TypeHandle);\r
+                       AssertEquals ("", FooClass.counter, 1);\r
+               }\r
+       }\r
+}\r