blob: 8dfeb785f592ee2a2cfe22d06133d6eb0d39d714 [file] [log] [blame]
Alexander Afanasyevb0c78ea2014-04-15 18:12:04 -07001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (C) 2014 Regents of the University of California.
4 * See COPYING for copyright and distribution information.
5 */
6
7#ifndef REPO_TESTS_DATASET_FIXTURES_HPP
8#define REPO_TESTS_DATASET_FIXTURES_HPP
9
10#include <ndn-cpp-dev/security/key-chain.hpp>
11
12namespace repo {
13namespace tests {
14
15static inline ndn::shared_ptr<ndn::Data>
16createData(const ndn::Name& name)
17{
18 static ndn::KeyChain keyChain;
19 static std::vector<uint8_t> content(1500, '-');
20
21 ndn::shared_ptr<ndn::Data> data = ndn::make_shared<ndn::Data>();
22 data->setName(name);
23 data->setContent(&content[0], content.size());
24 keyChain.sign(*data);
25
26 return data;
27}
28
29
30class DatasetBase
31{
32public:
33 typedef std::list<ndn::shared_ptr<ndn::Data> > DataContainer;
34 DataContainer data;
35
36 typedef std::list<std::pair<ndn::Interest, ndn::shared_ptr<ndn::Data> > > InterestContainer;
37 InterestContainer interests;
38};
39
40
41template<size_t N>
42class BaseSmoketestFixture : public DatasetBase
43{
44public:
45 static const std::string&
46 getName()
47 {
48 static std::string name = "BaseSmoketest";
49 return name;
50 }
51
52 BaseSmoketestFixture()
53 {
54 ndn::Name baseName("/x/y/z/test/1");
55 for (size_t i = 0; i < N; i++) {
56 ndn::Name name(baseName);
57 name.appendSegment(i);
58 ndn::shared_ptr<Data> data = createData(name);
59 this->data.push_back(data);
60
61 this->interests.push_back(std::make_pair(Interest(name), data));
62 }
63 }
64};
65
66
67class BaseTestFixture : public DatasetBase
68{
69public:
70 static const std::string&
71 getName()
72 {
73 static std::string name = "BaseTest";
74 return name;
75 }
76
77 BaseTestFixture()
78 {
79 this->data.push_back(createData("/a"));
80 this->interests.push_back(std::make_pair(Interest("/a"), this->data.back()));
81
82 this->data.push_back(createData("/a/b"));
83 this->interests.push_back(std::make_pair(Interest("/a/b"), this->data.back()));
84
85 this->data.push_back(createData("/a/b/c"));
86 this->interests.push_back(std::make_pair(Interest("/a/b/c"), this->data.back()));
87
88 this->data.push_back(createData("/a/b/c/d"));
89 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"), this->data.back()));
90 }
91};
92
93
94class FetchByPrefixTestFixture : public DatasetBase
95{
96public:
97 static const std::string&
98 getName()
99 {
100 static std::string name = "FetchByPrefix";
101 return name;
102 }
103
104 FetchByPrefixTestFixture()
105 {
106 this->data.push_back(createData("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"));
107 this->interests.push_back(std::make_pair(Interest("/a"),
108 this->data.back()));
109 this->interests.push_back(std::make_pair(Interest("/a/b"),
110 this->data.back()));
111 this->interests.push_back(std::make_pair(Interest("/a/b/c"),
112 this->data.back()));
113 this->interests.push_back(std::make_pair(Interest("/a/b/c/d"),
114 this->data.back()));
115 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e"),
116 this->data.back()));
117 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f"),
118 this->data.back()));
119 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g"),
120 this->data.back()));
121 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h"),
122 this->data.back()));
123 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i"),
124 this->data.back()));
125 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j"),
126 this->data.back()));
127 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k"),
128 this->data.back()));
129 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l"),
130 this->data.back()));
131 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m"),
132 this->data.back()));
133 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n"),
134 this->data.back()));
135 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o"),
136 this->data.back()));
137 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p"),
138 this->data.back()));
139 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q"),
140 this->data.back()));
141 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r"),
142 this->data.back()));
143 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s"),
144 this->data.back()));
145 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t"),
146 this->data.back()));
147 this->interests.push_back(std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u"),
148 this->data.back()));
149 this->interests.push_back(
150 std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v"),
151 this->data.back()));
152 this->interests.push_back(
153 std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w"),
154 this->data.back()));
155 this->interests.push_back(
156 std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x"),
157 this->data.back()));
158 this->interests.push_back(
159 std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y"),
160 this->data.back()));
161 this->interests.push_back(
162 std::make_pair(Interest("/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y/z"),
163 this->data.back()));
164 }
165};
166
167
168class SelectorTestFixture : public DatasetBase
169{
170public:
171 static const std::string&
172 getName()
173 {
174 static std::string name = "SelectorTest";
175 return name;
176 }
177
178 SelectorTestFixture()
179 {
180 this->data.push_back(createData("/a/1"));
181 this->data.push_back(createData("/b/1"));
182 this->interests.push_back(std::make_pair(Interest()
183 .setName("/b")
184 .setSelectors(Selectors()
185 .setChildSelector(0)),
186 this->data.back()));
187
188 this->data.push_back(createData("/c/1"));
189 this->data.push_back(createData("/b/99"));
190 this->interests.push_back(std::make_pair(Interest()
191 .setName("/b")
192 .setSelectors(Selectors()
193 .setChildSelector(1)),
194 this->data.back()));
195 this->data.push_back(createData("/b/5"));
196 this->data.push_back(createData("/b/55"));
197 }
198};
199
200
201typedef boost::mpl::vector< BaseTestFixture,
202 FetchByPrefixTestFixture,
203 SelectorTestFixture,
204 BaseSmoketestFixture<1>,
205 BaseSmoketestFixture<100> > DatasetFixtures;
206
207} // namespace tests
208} // namespace repo
209
210#endif // REPO_TESTS_DATASET_FIXTURES_HPP