Thread overview
Unit tests for libraries
May 14, 2005
Sebastian Beschke
May 14, 2005
Derek Parnell
May 14, 2005
Sebastian Beschke
May 16, 2005
Brian White
May 14, 2005
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
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
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 16, 2005
> 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.