build: stop defining _DEBUG, rely on NDEBUG instead
NDEBUG is more standard on non-Microsoft platforms
Change-Id: I6faec848b64abfc291b85903106fc48450943f9a
diff --git a/.waf-tools/default-compiler-flags.py b/.waf-tools/default-compiler-flags.py
index 2941fe1..6869097 100644
--- a/.waf-tools/default-compiler-flags.py
+++ b/.waf-tools/default-compiler-flags.py
@@ -136,7 +136,7 @@
def getDebugFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in debug mode"""
- return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': ['_DEBUG']}
+ return {'CXXFLAGS': [], 'LINKFLAGS': [], 'DEFINES': []}
def getOptimizedFlags(self, conf):
"""Get dict of CXXFLAGS, LINKFLAGS, and DEFINES that are needed only in optimized mode"""
diff --git a/tests/unit/ndebug.t.cpp b/tests/unit/ndebug.t.cpp
index 4fe1347..691b922 100644
--- a/tests/unit/ndebug.t.cpp
+++ b/tests/unit/ndebug.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2023 Regents of the University of California.
+ * Copyright (c) 2013-2024 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -27,24 +27,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
}