using System.Runtime.InteropServices.ComTypes;
using CoreFXTestLibrary;
-
public class CopyByteArrayTest
{
private byte[] TestArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for (int i = 0; i < array1.Length; i++)
if (!array1[i].Equals(array2[i]))
{
-
return false;
}
try
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
-
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
-
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
}
private void OutOfRangeTests()
try //try to copy more elements than the TestArray has
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
-
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
-
- }
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
+
}
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopyByteArrayTest().RunTests())
- return 100;
+ try
+ {
+ new CopyByteArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
- return 99;
+ return 100;
}
}
using System.Runtime.InteropServices.ComTypes;
using CoreFXTestLibrary;
-
public class CopyCharArrayTest
{
private char[] TestArray = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j' };
try
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- throw new Exception("No exception from Copy when passed null as parameter.");
+ Assert.Fail("No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
- {
+ {
+
}
-
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
-
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopyCharArrayTest().RunTests())
- return 100;
- return 99;
+ try
+ {
+ new CopyCharArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
+
+ return 100;
}
}
try
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
- CopyRoundTripTests();
- return true;
+ CopyRoundTripTests();
}
public static int Main(String[] unusedArgs)
{
- if (new CopyDoubleArrayTest().RunTests())
- return 100;
- return 99;
+ try
+ {
+ new CopyDoubleArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
+
+ return 100;
}
}
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
-
- NullValueTests();
- OutOfRangeTests();
+ NullValueTests();
+ OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopyInt16ArrayTest().RunTests())
- return 100;
- return 99;
+ try
+ {
+ new CopyInt16ArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
+
+ return 100;
}
}
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using CoreFXTestLibrary;
+
public class CopyInt32ArrayTest
{
private int[] TestArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopyInt32ArrayTest().RunTests())
- return 100;
- return 99;
+ try
+ {
+ new CopyInt32ArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
+
+ return 100;
}
}
using System.Runtime.InteropServices.ComTypes;
using CoreFXTestLibrary;
-
public class CopyInt64ArrayTest
{
private long[] TestArray = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopyInt64ArrayTest().RunTests())
- return 100;
- return 99;
+ try
+ {
+ new CopyInt64ArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
+
+ return 100;
}
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
using System;
using System.IO;
using System.Reflection;
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
}
private void OutOfRangeTests()
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy more elements than the TestArray has.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy more elements than the TestArray has.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from an out of bound startIndex.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from an out of bound startIndex.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
+ Assert.Fail("Failed out of range values test. No exception from Copy when trying to copy from a positive startIndex, with length taking it out of bounds.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
Marshal.FreeCoTaskMem(ptr);
}
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
- public bool Initialize()
+ public CopyIntPtrArrayTest()
{
TestArray = new IntPtr[10];
for (int i = 0; i < TestArray.Length; i++)
TestArray[i] = new IntPtr(i);
- return true;
}
public static int Main(String[] unusedArgs)
{
- CopyIntPtrArrayTest test = new CopyIntPtrArrayTest();
- test.Initialize();
-
- if (test.RunTests())
- return 100;
+ try
+ {
+ new CopyIntPtrArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
- return 99;
+ return 100;
}
-
}
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
+
using System;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using CoreFXTestLibrary;
-
public class CopySingleArrayTest
{
private float[] TestArray = { 0.0F, 1.0F, 2.0F, 3.0F, 4.0F, 5.0F, 6.0F, 7.0F, 8.0F, 9.0F };
for (int i = 0; i < array1.Length; i++)
if (!array1[i].Equals(array2[i]))
{
-
return false;
}
{
Marshal.Copy(array, 0, IntPtr.Zero, 0);
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("No exception from Copy when passed null as parameter.");
+ Assert.Fail("Failed null values test. No exception from Copy when passed null as parameter.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try
{
Marshal.Copy(IntPtr.Zero, array, 0, 0);
- Assert.ErrorWriteLine("Failed null values test.");
+ Assert.Fail("Failed null values test.");
}
catch (ArgumentNullException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed null values test.");
- }
}
private void OutOfRangeTests()
try //try to copy more elements than the TestArray has
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length + 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
+ Assert.Fail("Failed out of range values test.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
try //try to copy from an out of bound startIndex
{
Marshal.Copy(TestArray, TestArray.Length + 1, ptr, 1);
- Assert.ErrorWriteLine("Failed out of range values test.");
+ Assert.Fail("Failed out of range values test.");
}
catch (ArgumentOutOfRangeException)
{
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed out of range values test.");
- }
try //try to copy from a positive startIndex, with length taking it out of bounds
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length);
- Assert.ErrorWriteLine("Failed out of range values test.");
+ Assert.Fail("Failed out of range values test.");
}
catch (ArgumentOutOfRangeException)
- {
- }
- catch (Exception ex)
{
- Assert.ErrorWriteLine("Failed out of range values test.");
+
}
Marshal.FreeCoTaskMem(ptr);
IntPtr ptr = Marshal.AllocCoTaskMem(sizeOfArray);
- try //try to copy the entire array
+ //try to copy the entire array
{
Marshal.Copy(TestArray, 0, ptr, TestArray.Length);
if (!IsArrayEqual(TestArray, array))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- Assert.ErrorWriteLine("Exception occurred: {0}", ex);
- }
- try //try to copy part of the array
+ //try to copy part of the array
{
Marshal.Copy(TestArray, 2, ptr, TestArray.Length - 4);
if (!IsSubArrayEqual(TestArray, array, 2, TestArray.Length - 4))
{
- Assert.ErrorWriteLine("Failed copy round trip test");
- Assert.ErrorWriteLine("Original array and round trip partially copied arrays do not match.");
+ Assert.Fail("Failed copy round trip test. Original array and round trip partially copied arrays do not match.");
}
}
- catch (Exception ex)
- {
- Assert.ErrorWriteLine("Failed copy round trip test.");
- }
Marshal.FreeCoTaskMem(ptr);
}
- public bool RunTests()
+ public void RunTests()
{
NullValueTests();
OutOfRangeTests();
CopyRoundTripTests();
- return true;
}
public static int Main(String[] unusedArgs)
{
- if (new CopySingleArrayTest().RunTests())
- return 100;
+ try
+ {
+ new CopySingleArrayTest().RunTests();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Test failure: " + e.Message);
+ return 101;
+ }
- return 99;
+ return 100;
}
}
/// </summary>
public static class Assert
{
-
-
- public static void ErrorWriteLine(string message)
- {
- throw new Exception(message);
- }
-
- public static void ErrorWriteLine(string message,Exception ex)
- {
- throw new Exception(message,ex);
- }
-
/// <summary>
/// Asserts that the given delegate throws an <see cref="ArgumentNullException"/> with the given parameter name.
/// </summary>