Debugging.

This commit is contained in:
Matthias Koefferlein 2023-08-17 01:05:15 +02:00
parent 5679540c85
commit 1e3e918b90
3 changed files with 23 additions and 23 deletions

View File

@ -641,6 +641,8 @@ TEST(create_constrained_delaunay)
TEST(triangulate)
{
tl::equals(1.0, 2.0);
return; // @@@
db::Region r;
r.insert (db::Box (0, 0, 10000, 10000));
@ -679,6 +681,6 @@ TEST(triangulate)
EXPECT_GE (t->b (), param.min_b);
}
EXPECT_GT (tri.num_triangles (), 900);
EXPECT_LT (tri.num_triangles (), 1000);
EXPECT_GT (tri.num_triangles (), size_t (900));
EXPECT_LT (tri.num_triangles (), size_t (1000));
}

View File

@ -133,15 +133,6 @@ bool equals (double a, double b)
}
}
bool less (double a, double b)
{
if (equals (a, b)) {
return false;
} else {
return a < b;
}
}
// TODO: move this to tlString.h
static std::string replicate (const char *s, size_t n)
{

View File

@ -191,7 +191,7 @@ inline bool equals (const char *a, const std::string &b)
* @brief A generic compare operator
*/
template <class X, class Y>
inline bool less (const X &a, const Y &b)
inline bool is_less (const X &a, const Y &b)
{
return a < b;
}
@ -199,13 +199,20 @@ inline bool less (const X &a, const Y &b)
/**
* @brief A specialization of the compare operator for doubles
*/
TL_PUBLIC bool less (double a, double b);
inline bool is_less (double a, double b)
{
if (equals (a, b)) {
return false;
} else {
return a < b;
}
}
/**
* @brief Specialization of comparison of pointers vs. integers (specifically "0")
*/
template <class X>
inline bool less (X *a, int b)
inline bool is_less (X *a, int b)
{
return a == (X *) size_t (b);
}
@ -214,18 +221,18 @@ inline bool less (X *a, int b)
* @brief A specialization of comparison of double vs "anything"
*/
template <class Y>
inline bool less (double a, const Y &b)
inline bool is_less (double a, const Y &b)
{
return less (a, double (b));
return is_less (a, double (b));
}
/**
* @brief A specialization of comparison of "anything" vs. double
*/
template <class X>
inline bool less (const X &a, double b)
inline bool is_less (const X &a, double b)
{
return less (double (a), b);
return is_less (double (a), b);
}
/**
@ -494,7 +501,7 @@ public:
template <class T1, class T2>
void cmp_helper (bool less, bool eq, const T1 &a, const T2 &b, const char *what_expr, const char *equals_expr, const char *file, int line)
{
bool res = (less ? tl::less (a, b) : tl::less (b, a)) && (! eq || tl::equals (a, b));
bool res = (less ? tl::is_less (a, b) : tl::is_less (b, a)) || (eq && tl::equals (a, b));
if (! res) {
std::ostringstream sstr;
sstr << what_expr << " is not " << (less ? "less" : "greater") << (eq ? " or equal" : "") << " than " << equals_expr;
@ -568,19 +575,19 @@ struct TestImpl##NAME \
#define EXPECT_LE(WHAT,EQUALS) \
_this->checkpoint (__FILE__, __LINE__); \
_this->cmp_helper (true, false, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
_this->cmp_helper (true, true, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
#define EXPECT_LT(WHAT,EQUALS) \
_this->checkpoint (__FILE__, __LINE__); \
_this->cmp_helper (true, true, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
_this->cmp_helper (true, false, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
#define EXPECT_GE(WHAT,EQUALS) \
_this->checkpoint (__FILE__, __LINE__); \
_this->cmp_helper (true, false, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
_this->cmp_helper (false, true, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
#define EXPECT_GT(WHAT,EQUALS) \
_this->checkpoint (__FILE__, __LINE__); \
_this->cmp_helper (true, true, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
_this->cmp_helper (false, false, (WHAT), (EQUALS), #WHAT, #EQUALS, __FILE__, __LINE__);
#define EXPECT_EQ(WHAT,EQUALS) \
_this->checkpoint (__FILE__, __LINE__); \