blob: c65d1c2e8734f7e2b8e5211ad97f8bed8f984082 [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"
Steve DiBenedettobf6a93d2014-03-21 14:03:02 -060012#include "core/logger.hpp"
Junxiao Shif3c07812014-03-11 21:48:49 -070013#include <ndn-cpp-dev/security/key-chain.hpp>
Junxiao Shid9ee45c2014-02-27 15:38:11 -070014
15namespace nfd {
16namespace 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 */
23class BaseFixture
24{
25protected:
26 BaseFixture()
27 : g_io(getGlobalIoService())
28 {
29 }
Junxiao Shif3c07812014-03-11 21:48:49 -070030
Junxiao Shid9ee45c2014-02-27 15:38:11 -070031 ~BaseFixture()
32 {
33 resetGlobalIoService();
34 }
35
36protected:
37 /// reference to global io_service
38 boost::asio::io_service& g_io;
39};
40
Junxiao Shif3c07812014-03-11 21:48:49 -070041
42inline shared_ptr<Interest>
43makeInterest(const Name& name)
44{
45 return make_shared<Interest>(name);
46}
47
48inline shared_ptr<Data>
49makeData(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 Shid9ee45c2014-02-27 15:38:11 -070060} // namespace tests
61} // namespace nfd
62
63#endif // NFD_TEST_COMMON_HPP