using System.Reflection;
using System.Threading;
+#if !MOBILE
+using System.Diagnostics;
+#endif
+
using NUnit.Framework;
namespace MonoTests.System
}
}
+ // Several tests in this file, to run properly, allocate 4GB objects.
+ // Obviously this creates problems on several kinds of systems, so we
+ // conservatively skip these tests unless we find a high-RAM environment.
+ // Checking RAM requires PerformanceCounter which is absent on mobile,
+ // so any test that calls this must be category MobileNotWorking.
+ static void RequireHighMemoryTestEnvironment ()
+ {
+#if MOBILE
+ Assert.Ignore("PerformanceCounter not available.");
+#else
+ if (!Environment.Is64BitProcess)
+ Assert.Ignore("This test cannot run on a 32-bit system.");
+
+ // Require 6 GB available RAM, for the 4GB string plus 2GB headroom
+ var pc = new PerformanceCounter ("Mono Memory", "Available Physical Memory");
+
+ if (pc.RawValue < 6L*1024L*1024L*1024L)
+ Assert.Ignore("This machine may not have enough RAM to run this test.");
+#endif
+ }
+
+ [Test] // ctor (Char, Int32)
+ [Category ("MobileNotWorking")]
+ public void Constructor4_LargeString ()
+ {
+ RequireHighMemoryTestEnvironment();
+
+ var x = new String ('A', int.MaxValue);
+ Assert.AreEqual ('A', x[0]);
+ Assert.AreEqual ('A', x[int.MaxValue - 1]);
+ }
+
[Test] // ctor (Char [], Int32, Int32)
public void Constructor6 ()
{
}
[Test]
- public void PadLeft_Overflow ()
+ [Category ("MobileNotWorking")]
+ public void PadLeft_LargeString ()
{
- try {
- "x".PadLeft (int.MaxValue, '-');
- } catch (OutOfMemoryException) {
- }
+ RequireHighMemoryTestEnvironment();
+
+ var x = "x".PadLeft (int.MaxValue, '-');
+ Assert.AreEqual ('-', x[0]);
+ Assert.AreEqual ('x', x[int.MaxValue - 1]);
}
[Test] // PadRight (Int32)
}
[Test]
- public void PadRight_Overflow ()
+ [Category ("MobileNotWorking")]
+ public void PadRight_LargeString ()
{
- try {
- "x".PadRight (int.MaxValue, '-');
- } catch (OutOfMemoryException) {
- }
+ RequireHighMemoryTestEnvironment();
+
+ var x = "x".PadRight (int.MaxValue, '-');
+ Assert.AreEqual ('x', x[0]);
+ Assert.AreEqual ('-', x[int.MaxValue - 1]);
}
[Test] // Remove (Int32, Int32)