Unit tests in libraries?

Mike Linford mike.linford.reg at gmail.com
Mon Aug 16 19:24:03 PDT 2010


On Mon, 16 Aug 2010 17:38:28 -0700, Walter Bright wrote:

> Mike Linford wrote:
>> Is it working as it should by not including the unit tests with:
>> 
>> dmd -unittest -lib mylib.d
>> 
>> ?
> 
> That should work.

Yeah, I'm not sure what I'm doing wrong. Can someone else try this out?

mylib.d:

  1 module mylib;
  2 
  3 void blah()
  4 {
  5 }
  6 unittest
  7 {
  8    assert(false);
  9 }
 10 

test.d:

  1 module test;
  2 
  3 import mylib;
  4 
  5 void main()
  6 {
  7    blah();
  8 }
  9 


Makefile:
  1 test : mylib.a test.d
  2    dmd -unittest test.d mylib.a
  3 
  4 mylib.a : mylib.d
  5    dmd -unittest -lib mylib.d
  6 
  7 clean :
  8    rm -f test mylib.a *.o
  9 


-- 
Mike Linford


More information about the Digitalmars-d mailing list