0

We have attempted to reduce code duplication through the use of the TEST_GROUP_BASE to create a shared base class. When we attempt to use this TEST_GROUP_BASE in more than one test class, we get linker warnings complaining about 'getwchar'and 'putwchar': inconsistent dll linkage and errors reporting multiple definitions of both these functions, and a number of other 'char'/'wchar' pairs (e.g. strchr/wcschr, strpbrk/wcspbrk). If I only include one test file that makes use of the TEST_GROUP_BASE macro, the linker errors don't appear.

The base class is defined as a TEST_BASE in a .h file with all the member functions inlined. This .h file is then included in the derived test files with the TEST_GROUP_BASE macro used to incorporate the shared TEST_BASE. Have I missed anything?

I've not managed to find any examples of TEST_GROUP_BASE being used so I'm not sure whether I've missed a critical piece of configuration. We are testing legacy C code, but all references to the production code are made within extern "C" braces, since our simple tests pass that would suggest that the c/c++ is linking OK.

Can anyone suggest any possible causes, or point me in the direction of any opensource examples of how TEST_GROUP_BASE is being used elsewhere?

The development environment is VS2010.

PeeGee
  • 99
  • 8

1 Answers1

0

I'm not quite sure why there are errors on putwchar and getwchar, that probably is unrelated to TEST_BASE AND TEST_GROUP_BASE but probably relates to them being inline and the header file being included with different linkage. Without a code example, it would be hard to figure out where the different linkage problems come from, especially as you mentioned that it works with only one TEST_GROUP_BASE.

Probably the best way to resolve this problem though is to not put all the TEST_BASE functions inline in the header file. The TEST_BASE macro is actually very simple replacement for "struct testBaseClass : public Utest". So a TEST_BASE is simply any class that is sub-classed from Utest. That means that you can simply put the implementation in a cpp file.

One of the reasons why you can't find much usage of TEST_GROUP_BASE is that many people (including me) recommend against using it. It is often more flexible to put the parts that you want to re-use in a seperate class and use (rather than derive) that class in your TEST_GROUP. This allows for many smaller "fixture" classes that can be re-used across different tests.

Hope this helps.

Bas Vodde
  • 101
  • 4