[Mono-list] New NUnit test for System.Buffer class

Cesar Octavio Lopez Nataren cesar@ciencias.unam.mx
22 Jul 2002 22:30:32 -0500


--=-OO20Bhft/Kn3XVoA0dke
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hello, here is the diff from the ChangeLog, and the BufferTest it 's a
new test.


--=-OO20Bhft/Kn3XVoA0dke
Content-Disposition: attachment; filename=ChangeLogDiff.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=ChangeLogDiff.diff; charset=ISO-8859-15

Index: ChangeLog
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /mono/mcs/class/corlib/Test/System/ChangeLog,v
retrieving revision 1.101
diff -u -B -r1.101 ChangeLog
--- ChangeLog	17 Jul 2002 18:56:47 -0000	1.101
+++ ChangeLog	23 Jul 2002 03:24:38 -0000
@@ -1,3 +1,8 @@
+2002-07-22  Cesar Octavio Lopez Nataren  <cesar@ciencias.unam.mx>
+
+	* BufferTest.cs: Added this file to test the System.Buffer class=20
+	implementation.
+
 2002-07-17  Martin Baulig  <martin@gnome.org>
=20
 	* ConvertTest.cs: Commented out line 456 which contains a non-printable

--=-OO20Bhft/Kn3XVoA0dke
Content-Disposition: attachment; filename=BufferTest.cs
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; name=BufferTest.cs; charset=ISO-8859-15

// BufferTest.cs - NUnit Test Cases for the Buffer class.
//
// Cesar Octavio Lopez Nataren (cesar@ciencias.unam.mx)
//
// (C) Cesar Octavio Lopez Nataren 2002
//=20

using NUnit.Framework;
using System;


namespace MonoTests.System
{
	public class BufferTest : TestCase {
=09
	public BufferTest () : base ("System.Buffer test") {}
	public BufferTest (string name) : base(name) {}

	protected override void SetUp()=20
	{
		const int SIZE =3D 10;
		byte [] byteArray;   // 8-bits unsigned integer array
		float [] floatArray;
	=09
		byteArray =3D new byte [SIZE];
		floatArray =3D new float [SIZE];			=09
	}

	protected override void TearDown() {}

	public static ITest Suite {
		get {=20
			return new TestSuite(typeof(BufferTest));=20
		}
	}

=09
	public void TestBlockCopy ()
	{
		int [] myArray1 =3D new int [5] {1, 2, 3, 4, 5};
		int [] myArray2 =3D new int [10] { 0, 0, 0, 0, 0, 6, 7, 8, 9, 10 };
	=09
		Buffer.BlockCopy (myarr1, 0, myarr2, 0, 20);
	=09
		for (i =3D 0; i < 10; i++)=20
			AssertEquals ("TestBlockCopy Error", i + 1, myArray1 [i]);	=09
	}
=09
=09
	public void TestByteLength ()
	{
		int numBytes;=09
		bool errorThrown =3D false;
		floatArray =3D new float [10];
	=09
		try {
			Buffer.ByteLength (null);=09
		} catch (ArgumentNullException e) {
			errorThrown =3D true;
		}
		Assert ("TestByteLength: ArgumentNullException not thrown", errorThrown);
	=09
		errorThrown =3D false;
	=09
		// FIXME: test the case when the ArgumentException is thrown.
	=09
		numBytes =3D Buffer.ByteLength (floatArray);
		AssertEquals ("TestByteLength: wrong byteLength", 40, numBytes);
	}
	=09
	public void TestGetByte ()=20
	{
		Byte [] byteArray;
		bool errorThrown =3D false;
		byteArray =3D new byte [10];
		byteArray [5] =3D 8;
	=09
		try {
			Buffer.GetByte (null, 5);
		} catch (ArgumentNullException e) {
			errorThrown =3D true;
		}
		Assert ("TestGetByte: ArgumentNullException not thrown",
		        errorThrown);
	=09
		errorThrown =3D false;
	=09
		try {
			Buffer.GetByte (byteArray, -1);
		} catch (ArgumentOutOfRangeException e) {
			errorThrown =3D true;
		}
		Assert ("TestGetByte: ArgumentOutOfRangeException (negative index) not im=
plemented",
		        errorThrown);
	=09
		errorThrown =3D false;
	=09
		try {
			Buffer.GetByte (byteArray, 12);=20
		} catch (ArgumentOutOfRangeException e) {
			errorThrown =3D true;
		}
		Assert ("TestGetByte: ArgumentOutOfRangeException (index bigger/equal tha=
n array's size not thrown", errorThrown);
	=09
		errorThrown =3D false;
	=09
		// FIXME: test the case when the ArgumentException is thrown.
	=09
		AssertEquals ("TestGetByte Error", 8, Buffer.GetByte (byteArray, 5));
	}
=09
=09
	public void TestSetByte ()
	{
		char foo;
		foo =3D 255;
		bool errorThrown =3D false;
	=09
		try {
			Buffer.SetByte (null, 5, 12);
		} catch (ArgumentNullException e) {
			errorThown =3D true;
		}
		Assert ("TestSetByte: ArgumentNullException not thrown", errorThrown);
		errorThrown =3D false;
	=09
		try {
			Buffer.SetByte (byteArray, -1, 32);
		} catch (ArgumentOutOfRangeException e) {
			errorThown =3D true;
		}
		Assert ("TestSetByte: ArgumentOutOfRangeException (case: negative index) =
not thrown",
		        errorThrown);
		errorThrown =3D false;
	=09
		try {
			Buffer.SetByte (byteArray, 12, 43);
		} catch (ArgumentOutOfRangeException e) {
			errorThrown =3D true;
		}
		Assert ("TestSetByte: ArgumentOutOfRangeException (case: index bigger/equ=
al than array'size",
		        errorThrown);
		errorThrown =3D false;
	=09
		// FIXME: test the case when the ArgumentException is thrown
		=09
		Buffer.SetByte (byteArray, 3, (byte) 10);
		AssertEquals ("TestSetByte", 10, Buffer.GetByte (byteArray, 3));
	}
	}
}

--=-OO20Bhft/Kn3XVoA0dke--