37 if (
os_) cout <<
"Testing BinaryIndexStream (single thread)" << endl;
39 shared_ptr<stringstream> indexStreamPtr(
new stringstream);
43 vector<Index::Entry> entries;
44 for (
size_t i=0; i < 10; ++i)
47 entry.
id = lexical_cast<string>(i);
50 entries.push_back(entry);
61 for (
size_t i=0; i < 10; ++i)
65 unit_assert(entryPtr->id == lexical_cast<string>(i));
69 entryPtr = index.
find(entryPtr->id);
71 unit_assert(entryPtr->id == lexical_cast<string>(i));
87 for (
size_t i=0; i < 10; ++i)
91 unit_assert(entryPtr->id == lexical_cast<string>(i));
95 entryPtr = index.
find(entryPtr->id);
97 unit_assert(entryPtr->id == lexical_cast<string>(i));
108 vector<Index::Entry> entries;
109 for (
size_t i=0; i < 5; ++i)
112 entry.
id = lexical_cast<string>(i);
115 entries.push_back(entry);
124 for (
size_t i=0; i < 5; ++i)
128 unit_assert(entryPtr->id == lexical_cast<string>(i));
132 entryPtr = index.
find(entryPtr->id);
134 unit_assert(entryPtr->id == lexical_cast<string>(i));
182 if (
os_) cout <<
"Testing BinaryIndexStream (multithreaded)" << endl;
184 shared_ptr<stringstream> indexStreamPtr(
new stringstream);
187 vector<Index::Entry> entries;
188 for (
size_t i=0; i < 10; ++i)
191 entry.
id = lexical_cast<string>(i);
194 entries.push_back(entry);
202 const int testThreadCount = 100;
203 boost::barrier testBarrier(testThreadCount);
204 boost::thread_group testThreadGroup;
205 for (
int i=0; i < testThreadCount; ++i)
207 testThreadGroup.join_all();
generic type identifying an indexed item by string id, ordinal index, and stream offset