www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Unit tests for libraries

reply Sebastian Beschke <s.beschke gmx.de> writes:
Hi,

I'm still having problems understanding how unit tests work.
I'm trying to incorporate unit tests into a library. Is there any way to 
create an executable that runs the unit tests, without linking an extra 
main() function in? I haven't yet found a way to do this.

Thanks,
Sebastian
May 14 2005
next sibling parent reply Derek Parnell <derek psych.ward> writes:
On Sat, 14 May 2005 15:08:22 +0200, Sebastian Beschke wrote:

 Hi,
 
 I'm still having problems understanding how unit tests work.
 I'm trying to incorporate unit tests into a library. Is there any way to 
 create an executable that runs the unit tests, without linking an extra 
 main() function in? I haven't yet found a way to do this.

No, I don't think so. You might try something like this ... version(mytest) { void main(){} } then compile the library with -version=mytest -unittest -- Derek Parnell Melbourne, Australia 14/05/2005 11:49:11 PM
May 14 2005
parent Sebastian Beschke <s.beschke gmx.de> writes:
Derek Parnell schrieb:
 You might try something like this ...
 
   version(mytest)
   {
    void main(){}
   }
 
 then compile the library with -version=mytest -unittest

Yeah, that sounds OK. Thanks :) -Sebastian
May 14 2005
prev sibling parent Brian White <bcwhite precidia.com> writes:
 I'm still having problems understanding how unit tests work.
 I'm trying to incorporate unit tests into a library. Is there any way to 
 create an executable that runs the unit tests, without linking an extra 
 main() function in? I haven't yet found a way to do this.

What I do is, after building the library, is link all of the .o files along with "testmain.o". That creates a standard library and also an executable to run the unit tests. Brian ( bcwhite precidia.com ) ------------------------------------------------------------------------------- Differences are good. If two people agree, one of them is redundant.
May 16 2005