|
From: Mark E. <ma...@eg...> - 2003-05-20 17:49:33
|
Earnie Boyd wrote:
[using dlls]
John Brown wrote:
>How about conditional compilation?
These are both in the same direction and with the conditional I'm
already working but they don't overcome the problem that I have to
create a separate file for single-unit testing. The directory is
cluttered already so I thought it would be nice to have a main in the
unit. Hm, I think code says more then words, so that's what I was trying:
<file name="hello.c">
void hello() {}
#ifdef TEST
void hellotest() {
hello();
}
int hellotestmain() {
hellotest();
}
#endif // TEST
</file>
<file name="alltests.c">
int alltestsmain() {
hellotest();
}
</file>
g++ hello.c -c // for normal use
g++ -DTEST hello.c -c -o testhello.o // for testing purposes
g++ alltests.c -c
g++ alltests.o testhello.o -Wl,-e,_alltestsmain -o alltests
g++ testhello.o -Wl,-e,_hellotestmain -o hellotest
This way I could test each unit on its own or all together
tnx
|