Commit 5ff46cb0 authored by Mukund Sivaraman's avatar Mukund Sivaraman
Browse files

Merge branch 'trac1366'

parents 99ca7567 477969e3
......@@ -17,6 +17,8 @@
#include <iostream>
#include <exceptions/exceptions.h>
#include <asio/error.hpp>
#include <asio/error_code.hpp>
......@@ -39,20 +41,30 @@ public:
/// \brief Asynchronous I/O callback method
///
/// TODO: explain why this method should never be called.
/// This should be unused.
void operator()(asio::error_code)
{
// TODO: log an error if this method ever gets called.
/// Should never be called, as this class is a convenience class provided
/// for instances where a socket is required but it is known that no
/// asynchronous operations will be carried out.
void operator()(asio::error_code) {
// If the function is called, there is a serious logic error in
// the program (this class should not be used as the callback
// class). As the asiolink module is too low-level for logging
// errors, throw an exception.
isc_throw(isc::Unexpected,
"DummyIOCallback::operator() must not be called");
}
/// \brief Asynchronous I/O callback method
///
/// TODO: explain why this method should never be called.
/// This should be unused.
void operator()(asio::error_code, size_t)
{
// TODO: log an error if this method ever gets called.
/// Should never be called, as this class is a convenience class provided
/// for instances where a socket is required but it is known that no
/// asynchronous operations will be carried out.
void operator()(asio::error_code, size_t) {
// If the function is called, there is a serious logic error in
// the program (this class should not be used as the callback
// class). As the asiolink module is too low-level for logging
// errors, throw an exception.
isc_throw(isc::Unexpected,
"DummyIOCallback::operator() must not be called");
}
};
......
......@@ -35,6 +35,7 @@ run_unittests_SOURCES += udp_endpoint_unittest.cc
run_unittests_SOURCES += udp_socket_unittest.cc
run_unittests_SOURCES += io_service_unittest.cc
run_unittests_SOURCES += local_socket_unittest.cc
run_unittests_SOURCES += dummy_io_callback_unittest.cc
run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
......
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
#include <config.h>
#include <gtest/gtest.h>
#include <asio.hpp>
#include <asiolink/dummy_io_cb.h>
using namespace isc::asiolink;
using namespace asio;
namespace { // begin unnamed namespace
TEST(DummyIOCallbackTest, throws) {
DummyIOCallback cb;
asio::error_code error_code;
// All methods should throw isc::Unexpected.
EXPECT_THROW(cb(error_code), isc::Unexpected);
EXPECT_THROW(cb(error_code, 42), isc::Unexpected);
}
} // end of unnamed namespace
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment