[Aptitude-svn-commit] r3689 - in branches/aptitude-0.3/aptitude: .
src/generic/tests
Daniel Burrows
dburrows at costa.debian.org
Tue Jul 26 04:12:02 UTC 2005
Author: dburrows
Date: Tue Jul 26 04:12:00 2005
New Revision: 3689
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/generic/tests/test_tags.cc
Log:
Add specialized macros to do comparison tests.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Tue Jul 26 04:12:00 2005
@@ -1,5 +1,9 @@
2005-07-25 Daniel Burrows <dburrows at debian.org>
+ * src/generic/tests/test_tags.cc:
+
+ Add specialized test forms for comparison tests.
+
* src/generic/tags.cc:
Fix an incorrect bounds-check (I tested an iterator on the
Modified: branches/aptitude-0.3/aptitude/src/generic/tests/test_tags.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/tests/test_tags.cc (original)
+++ branches/aptitude-0.3/aptitude/src/generic/tests/test_tags.cc Tue Jul 26 04:12:00 2005
@@ -24,11 +24,41 @@
#include <string.h>
+#include <sstream>
+
std::ostream &operator<<(std::ostream &out, const tag &t)
{
return out << t.str();
}
+#define CPPUNIT_ASSERT_GT(a, b) \
+ do { if(!((a) > (b))) \
+ {std::ostringstream out; \
+ out << "comparison assertion failed" << std::endl; \
+ out << "\"" << (a) << "\" is not > \"" << (b) << "\"" << std::endl; \
+ CppUnit :: Asserter :: fail(out.str()); } } while(0)
+
+#define CPPUNIT_ASSERT_LT(a, b) \
+ do { if(!((a) < (b))) \
+ {std::ostringstream out; \
+ out << "comparison assertion failed" << std::endl; \
+ out << "\"" << (a) << "\" is not < \"" << (b) << "\"" << std::endl; \
+ CppUnit :: Asserter :: fail(out.str()); } } while(0)
+
+#define CPPUNIT_ASSERT_LTEQUAL(a, b) \
+ do { if(!((a) <= (b))) \
+ {std::ostringstream out; \
+ out << "comparison assertion failed" << std::endl; \
+ out << "\"" << (a) << "\" is not <= \"" << (b) << "\"" << std::endl; \
+ CppUnit :: Asserter :: fail(out.str()); } } while(0)
+
+#define CPPUNIT_ASSERT_GTEQUAL(a, b) \
+ do { if(!((a) >= (b))) \
+ {std::ostringstream out; \
+ out << "comparison assertion failed" << std::endl; \
+ out << "\"" << (a) << "\" is not >= \"" << (b) << "\"" << std::endl; \
+ CppUnit :: Asserter :: fail(out.str()); } } while(0)
+
class TagTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(TagTest);
@@ -127,13 +157,13 @@
{
tag pt = parseTag(*t);
- CPPUNIT_ASSERT(ps <= pt);
- CPPUNIT_ASSERT(pt >= ps);
+ CPPUNIT_ASSERT_LTEQUAL(ps, pt);
+ CPPUNIT_ASSERT_GTEQUAL(pt, ps);
if(t != s)
{
- CPPUNIT_ASSERT(ps < pt);
- CPPUNIT_ASSERT(ps > pt);
+ CPPUNIT_ASSERT_LT(ps, pt);
+ CPPUNIT_ASSERT_GT(ps, pt);
}
}
}
More information about the Aptitude-svn-commit
mailing list