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" |
Steve DiBenedetto | bf6a93d | 2014-03-21 14:03:02 -0600 | [diff] [blame] | 12 | #include "core/logger.hpp" |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 13 | #include <ndn-cpp-dev/security/key-chain.hpp> |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 14 | |
| 15 | namespace nfd { |
| 16 | namespace tests { |
| 17 | |
| 18 | /** \brief base test fixture |
| 19 | * |
| 20 | * Every test case should be based on this fixture, |
| 21 | * to have per test case io_service initialization. |
| 22 | */ |
| 23 | class BaseFixture |
| 24 | { |
| 25 | protected: |
| 26 | BaseFixture() |
| 27 | : g_io(getGlobalIoService()) |
| 28 | { |
| 29 | } |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 30 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 31 | ~BaseFixture() |
| 32 | { |
| 33 | resetGlobalIoService(); |
| 34 | } |
| 35 | |
| 36 | protected: |
| 37 | /// reference to global io_service |
| 38 | boost::asio::io_service& g_io; |
| 39 | }; |
| 40 | |
Junxiao Shi | f3c0781 | 2014-03-11 21:48:49 -0700 | [diff] [blame] | 41 | |
| 42 | inline shared_ptr<Interest> |
| 43 | makeInterest(const Name& name) |
| 44 | { |
| 45 | return make_shared<Interest>(name); |
| 46 | } |
| 47 | |
| 48 | inline shared_ptr<Data> |
| 49 | makeData(const Name& name) |
| 50 | { |
| 51 | shared_ptr<Data> data = make_shared<Data>(name); |
| 52 | |
| 53 | ndn::SignatureSha256WithRsa fakeSignature; |
| 54 | fakeSignature.setValue(ndn::dataBlock(tlv::SignatureValue, reinterpret_cast<const uint8_t*>(0), 0)); |
| 55 | data->setSignature(fakeSignature); |
| 56 | |
| 57 | return data; |
| 58 | } |
| 59 | |
Junxiao Shi | d9ee45c | 2014-02-27 15:38:11 -0700 | [diff] [blame] | 60 | } // namespace tests |
| 61 | } // namespace nfd |
| 62 | |
| 63 | #endif // NFD_TEST_COMMON_HPP |