Replace all uses of BOOST_THROW_EXCEPTION with NDN_THROW
Refs: #4834
Change-Id: I1f9a614c83954873888d13c7b2b17a4fbff81058
diff --git a/tests/unit/lp/packet.t.cpp b/tests/unit/lp/packet.t.cpp
index a8b5819..30c8bae 100644
--- a/tests/unit/lp/packet.t.cpp
+++ b/tests/unit/lp/packet.t.cpp
@@ -44,7 +44,7 @@
packet.set<FragIndexField>(1234);
BOOST_CHECK(!packet.empty());
BOOST_CHECK(packet.has<FragIndexField>());
- BOOST_CHECK_THROW(packet.add<FragIndexField>(5678), std::length_error);
+ BOOST_CHECK_THROW(packet.add<FragIndexField>(5678), std::invalid_argument);
BOOST_CHECK_EQUAL(packet.count<FragIndexField>(), 1);
BOOST_CHECK_EQUAL(packet.get<FragIndexField>(0), 1234);
BOOST_CHECK_THROW(packet.get<FragIndexField>(1), std::out_of_range);
diff --git a/tests/unit/mgmt/dispatcher.t.cpp b/tests/unit/mgmt/dispatcher.t.cpp
index c24f9cf..7fa74e5 100644
--- a/tests/unit/mgmt/dispatcher.t.cpp
+++ b/tests/unit/mgmt/dispatcher.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -68,7 +68,7 @@
wireDecode(const Block& wire) final
{
if (wire.type() != 128)
- BOOST_THROW_EXCEPTION(tlv::Error("Expecting TLV type 128"));
+ NDN_THROW(tlv::Error("Expecting TLV type 128"));
}
};
diff --git a/tests/unit/util/io.t.cpp b/tests/unit/util/io.t.cpp
index 052e149..f8595c9 100644
--- a/tests/unit/util/io.t.cpp
+++ b/tests/unit/util/io.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -93,7 +93,7 @@
wireEncode() const
{
if (shouldThrow) {
- BOOST_THROW_EXCEPTION(tlv::Error("encode error"));
+ NDN_THROW(tlv::Error("encode error"));
}
// block will be 0xAA, 0x01, 0xDD
@@ -120,7 +120,7 @@
wireDecode(const Block& block)
{
if (m_shouldThrow) {
- BOOST_THROW_EXCEPTION(tlv::Error("decode error"));
+ NDN_THROW(tlv::Error("decode error"));
}
// block must be 0xBB, 0x01, 0xEE
diff --git a/tests/unit/util/scheduler.t.cpp b/tests/unit/util/scheduler.t.cpp
index 49c90b6..d8335c4 100644
--- a/tests/unit/util/scheduler.t.cpp
+++ b/tests/unit/util/scheduler.t.cpp
@@ -85,7 +85,12 @@
class MyException : public std::exception
{
};
- scheduler.scheduleEvent(10_ms, [] { BOOST_THROW_EXCEPTION(MyException()); });
+ scheduler.scheduleEvent(10_ms, [] {
+ // use plain 'throw' to ensure that Scheduler does not depend on the
+ // internal machinery of NDN_THROW and that it can catch all exceptions
+ // regardless of how they are thrown by the application
+ throw MyException{};
+ });
bool isCallbackInvoked = false;
scheduler.scheduleEvent(20_ms, [&isCallbackInvoked] { isCallbackInvoked = true; });
diff --git a/tests/unit/util/signal.t.cpp b/tests/unit/util/signal.t.cpp
index de22534..f0eb192 100644
--- a/tests/unit/util/signal.t.cpp
+++ b/tests/unit/util/signal.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -424,14 +424,17 @@
{
SignalOwner0 so;
- struct HandlerError : public std::exception
+ class HandlerError : public std::exception
{
};
int hit = 0;
so.sig.connect([&] {
++hit;
- BOOST_THROW_EXCEPTION(HandlerError());
+ // use plain 'throw' to ensure that Signal does not depend on the internal
+ // machinery of NDN_THROW and that it can catch all exceptions regardless
+ // of how they are thrown by the application
+ throw HandlerError{};
});
BOOST_CHECK_THROW(so.emitSignal(sig), HandlerError);
diff --git a/tests/unit/util/simple-notification.hpp b/tests/unit/util/simple-notification.hpp
index ac81f5f..431b8c2 100644
--- a/tests/unit/util/simple-notification.hpp
+++ b/tests/unit/util/simple-notification.hpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2014-2018 Regents of the University of California,
+ * Copyright (c) 2014-2019 Regents of the University of California,
* Arizona Board of Regents,
* Colorado State University,
* University Pierre & Marie Curie, Sorbonne University,
@@ -68,7 +68,7 @@
// error for testing
if (!m_message.empty() && m_message[0] == '\x07')
- BOOST_THROW_EXCEPTION(tlv::Error("0x07 error"));
+ NDN_THROW(tlv::Error("0x07 error"));
}
const std::string&
diff --git a/tests/unit/util/time.t.cpp b/tests/unit/util/time.t.cpp
index 6ed55d5..3f5f531 100644
--- a/tests/unit/util/time.t.cpp
+++ b/tests/unit/util/time.t.cpp
@@ -1,6 +1,6 @@
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
- * Copyright (c) 2013-2018 Regents of the University of California.
+ * Copyright (c) 2013-2019 Regents of the University of California.
*
* This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions).
*
@@ -23,6 +23,7 @@
#include "tests/boost-test.hpp"
+#include <boost/lexical_cast.hpp>
#include <thread>
namespace ndn {
@@ -125,8 +126,10 @@
auto year2042 = fromIsoString("20420101T000001.042000");
auto year2010 = fromIsoString("20100101T000001.042000");
- BOOST_CHECK_EQUAL(to_string(year2010), "1262304001042000000 nanoseconds since Jan 1, 1970");
- BOOST_CHECK_EQUAL(to_string(year2042), "2272147201042000000 nanoseconds since Jan 1, 1970");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(year2010),
+ "1262304001042000000 nanoseconds since Jan 1, 1970");
+ BOOST_CHECK_EQUAL(boost::lexical_cast<std::string>(year2042),
+ "2272147201042000000 nanoseconds since Jan 1, 1970");
BOOST_CHECK_GT(year2042, year2010);
}