Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_TEST_COMMON_HPP |
| 8 | #define NFD_TEST_COMMON_HPP |
| 9 | |
| 10 | #include <boost/test/unit_test.hpp> |
| 11 | #include "core/global-io.hpp" |
| 12 | |
| 13 | namespace nfd { |
| 14 | namespace tests { |
| 15 | |
| 16 | /** \brief base test fixture |
| 17 | * |
| 18 | * Every test case should be based on this fixture, |
| 19 | * to have per test case io_service initialization. |
| 20 | */ |
| 21 | class BaseFixture |
| 22 | { |
| 23 | protected: |
| 24 | BaseFixture() |
| 25 | : g_io(getGlobalIoService()) |
| 26 | { |
| 27 | } |
| 28 | |
| 29 | ~BaseFixture() |
| 30 | { |
| 31 | resetGlobalIoService(); |
| 32 | } |
| 33 | |
| 34 | protected: |
| 35 | /// reference to global io_service |
| 36 | boost::asio::io_service& g_io; |
| 37 | }; |
| 38 | |
| 39 | } // namespace tests |
| 40 | } // namespace nfd |
| 41 | |
| 42 | #endif // NFD_TEST_COMMON_HPP |