blob: 8095431308544befb17bd54b7561b29c0908a834 [file] [log] [blame]
Junxiao Shid9ee45c2014-02-27 15:38:11 -07001/* -*- 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 Shif3c07812014-03-11 21:48:49 -070012#include <ndn-cpp-dev/security/key-chain.hpp>
Junxiao Shid9ee45c2014-02-27 15:38:11 -070013
14namespace nfd {
15namespace 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 */
22class BaseFixture
23{
24protected:
25 BaseFixture()
26 : g_io(getGlobalIoService())
27 {
28 }
Junxiao Shif3c07812014-03-11 21:48:49 -070029
Junxiao Shid9ee45c2014-02-27 15:38:11 -070030 ~BaseFixture()
31 {
32 resetGlobalIoService();
33 }
34
35protected:
36 /// reference to global io_service
37 boost::asio::io_service& g_io;
38};
39
Junxiao Shif3c07812014-03-11 21:48:49 -070040
41inline shared_ptr<Interest>
42makeInterest(const Name& name)
43{
44 return make_shared<Interest>(name);
45}
46
47inline shared_ptr<Data>
48makeData(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 Shid9ee45c2014-02-27 15:38:11 -070059} // namespace tests
60} // namespace nfd
61
62#endif // NFD_TEST_COMMON_HPP