tests: use preconditions to skip test cases
Change-Id: I33e239ef033f9b991a425e20326d8dfdb5318095
diff --git a/tests/unit/net/network-configuration-detector.hpp b/tests/unit/net/network-configuration-detector.hpp
index 7264e68..58abba0 100644
--- a/tests/unit/net/network-configuration-detector.hpp
+++ b/tests/unit/net/network-configuration-detector.hpp
@@ -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).
*
@@ -22,50 +22,42 @@
#ifndef NDN_CXX_TESTS_UNIT_NET_NETWORK_CONFIGURATION_DETECTOR_HPP
#define NDN_CXX_TESTS_UNIT_NET_NETWORK_CONFIGURATION_DETECTOR_HPP
-#define SKIP_IF_IPV4_UNAVAILABLE() \
- do { \
- if (!::ndn::tests::NetworkConfigurationDetector::hasIpv4()) { \
- BOOST_WARN_MESSAGE(false, "skipping assertions that require IPv4 support"); \
- return; \
- } \
- } while (false)
-
-#define SKIP_IF_IPV6_UNAVAILABLE() \
- do { \
- if (!::ndn::tests::NetworkConfigurationDetector::hasIpv6()) { \
- BOOST_WARN_MESSAGE(false, "skipping assertions that require IPv6 support"); \
- return; \
- } \
- } while (false)
-
-#define SKIP_IF_IP_UNAVAILABLE() \
- do { \
- if (!::ndn::tests::NetworkConfigurationDetector::hasIpv4() && \
- !::ndn::tests::NetworkConfigurationDetector::hasIpv6()) { \
- BOOST_WARN_MESSAGE(false, "skipping assertions that require either IPv4 or IPv6 support"); \
- return; \
- } \
- } while (false)
+#include "tests/boost-test.hpp"
namespace ndn::tests {
class NetworkConfigurationDetector
{
public:
- static bool
- hasIpv4();
+ static boost::test_tools::assertion_result
+ hasIpv4(ut::test_unit_id = {})
+ {
+ detect();
+ return s_hasIpv4;
+ }
- static bool
- hasIpv6();
+ static boost::test_tools::assertion_result
+ hasIpv6(ut::test_unit_id = {})
+ {
+ detect();
+ return s_hasIpv6;
+ }
+
+ static boost::test_tools::assertion_result
+ hasIpv4OrIpv6(ut::test_unit_id = {})
+ {
+ detect();
+ return s_hasIp;
+ }
private:
static void
detect();
private:
- static inline bool s_isInitialized = false;
- static inline bool s_hasIpv4 = false;
- static inline bool s_hasIpv6 = false;
+ static inline boost::test_tools::assertion_result s_hasIp = false;
+ static inline boost::test_tools::assertion_result s_hasIpv4 = false;
+ static inline boost::test_tools::assertion_result s_hasIpv6 = false;
};
} // namespace ndn::tests