build: stop defining _DEBUG, rely only on NDEBUG instead
NDEBUG is more standard on non-Microsoft platforms, and _DEBUG is
technically a reserved identifier.
Change-Id: I24c951032d50b37853dc1a38ac844b0be5ac8937
diff --git a/tests/core/ndebug.t.cpp b/tests/core/ndebug.t.cpp
index 99e8938..4e4a2d9 100644
--- a/tests/core/ndebug.t.cpp
+++ b/tests/core/ndebug.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -31,24 +31,25 @@
BOOST_AUTO_TEST_SUITE(TestNdebug)
-BOOST_AUTO_TEST_CASE(AssertFalse)
+BOOST_AUTO_TEST_CASE(Assert)
{
-#ifndef _DEBUG
+ BOOST_TEST(BOOST_IS_DEFINED(BOOST_ASSERT_IS_VOID) == BOOST_IS_DEFINED(NDEBUG));
+
+#ifdef NDEBUG
// in release builds, assertion shouldn't execute
BOOST_ASSERT(false);
+ BOOST_VERIFY(false);
#endif
- // Trivial check to avoid "test case did not check any assertions" message from Boost.Test
- BOOST_CHECK(true);
}
BOOST_AUTO_TEST_CASE(SideEffect)
{
int a = 1;
BOOST_ASSERT((a = 2) > 0);
-#ifdef _DEBUG
- BOOST_CHECK_EQUAL(a, 2);
+#ifdef NDEBUG
+ BOOST_TEST(a == 1);
#else
- BOOST_CHECK_EQUAL(a, 1);
+ BOOST_TEST(a == 2);
#endif
}
diff --git a/tests/other/cs-benchmark.cpp b/tests/other/cs-benchmark.cpp
index 793ccf1..4446d31 100644
--- a/tests/other/cs-benchmark.cpp
+++ b/tests/other/cs-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -39,7 +39,7 @@
protected:
CsBenchmarkFixture()
{
-#ifdef _DEBUG
+#ifndef NDEBUG
std::cerr << "Benchmark compiled in debug mode is unreliable, please compile in release mode.\n";
#endif
diff --git a/tests/other/face-benchmark.cpp b/tests/other/face-benchmark.cpp
index c5c666d..4c1ac6a 100644
--- a/tests/other/face-benchmark.cpp
+++ b/tests/other/face-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2023, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -177,7 +177,7 @@
int
main(int argc, char** argv)
{
-#ifdef _DEBUG
+#ifndef NDEBUG
std::cerr << "Benchmark compiled in debug mode is unreliable, please compile in release mode.\n";
#endif
diff --git a/tests/other/pit-fib-benchmark.cpp b/tests/other/pit-fib-benchmark.cpp
index a154297..f750f90 100644
--- a/tests/other/pit-fib-benchmark.cpp
+++ b/tests/other/pit-fib-benchmark.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2022, Regents of the University of California,
+ * Copyright (c) 2014-2024, Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -42,7 +42,7 @@
: m_fib(m_nameTree)
, m_pit(m_nameTree)
{
-#ifdef _DEBUG
+#ifndef NDEBUG
std::cerr << "Benchmark compiled in debug mode is unreliable, please compile in release mode.\n";
#endif
}