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