www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Unittest question

reply Regan Heath <regan netwin.co.nz> writes:
What is the correct way to add a unittest for a class.. I did the 
following:

class MD5 {

	unittest {
		auto MD5 m = new MD5();

		m.reset();
		m.process("");
		assert(m.toString() == "d41d8cd98f00b204e9800998ecf8427e");

..etc..

but I note in the std.md5 source the unittest is coded at the end of the 
file, at file scope.
std.md5 uses a struct and I have used a class, is that why? or have I done 
it wrong?

Regan.

-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 07 2004
parent reply "Walter" <newshound digitalmars.com> writes:
You can do it either way.
Jun 07 2004
parent reply Regan Heath <regan netwin.co.nz> writes:
On Mon, 7 Jun 2004 11:15:44 -0700, Walter <newshound digitalmars.com> 
wrote:
 You can do it either way.
Does it make any difference? Scoping? etc? -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 07 2004
parent "Walter" <newshound digitalmars.com> writes:
"Regan Heath" <regan netwin.co.nz> wrote in message
news:opr88ux7pg5a2sq9 digitalmars.com...
 On Mon, 7 Jun 2004 11:15:44 -0700, Walter <newshound digitalmars.com>
 wrote:
 You can do it either way.
Does it make any difference? Scoping? etc?
The scoping rules still apply.
Jun 07 2004