Commit 9df9a9bd authored by Matthieu Dorier's avatar Matthieu Dorier

added even more tests

parent cd411b09
......@@ -239,3 +239,61 @@ void RunSetTest::testPrefetcher() {
}
}
}
void RunSetTest::testAsyncPrefetcher() {
auto root = datastore->root();
DataSet mds = root.createDataSet("matthieu_prefetch");
CPPUNIT_ASSERT(mds.valid());
for(unsigned i=0; i < 20; i++) {
Run r = mds.createRun(i);
CPPUNIT_ASSERT(r.valid());
}
// test begin/end
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=0;
for(auto it = mds.runs().begin(prefetcher); it != mds.runs().end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
}
// test begin/end using a Prefetchable object
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetch(*datastore, async);
unsigned i=0;
for(auto& r : prefetch(mds.runs())) {
CPPUNIT_ASSERT(r.valid());
CPPUNIT_ASSERT(r.number() == i);
i += 1;
}
}
// test lower_bound
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=5;
auto it = mds.runs().lower_bound(5, prefetcher);
for(; it != mds.runs().end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
}
// test upper_bound
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=6;
auto it = mds.runs().upper_bound(5, prefetcher);
for(; it != mds.runs().end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
}
}
......@@ -17,6 +17,7 @@ class RunSetTest : public CppUnit::TestFixture
CPPUNIT_TEST( testCreateSubRuns );
CPPUNIT_TEST( testAsync );
CPPUNIT_TEST( testPrefetcher );
CPPUNIT_TEST( testAsyncPrefetcher );
CPPUNIT_TEST_SUITE_END();
public:
......@@ -32,6 +33,7 @@ class RunSetTest : public CppUnit::TestFixture
void testCreateSubRuns();
void testAsync();
void testPrefetcher();
void testAsyncPrefetcher();
};
#endif
......@@ -244,3 +244,55 @@ void SubRunTest::testPrefetcher() {
}
}
}
void SubRunTest::testAsyncPrefetcher() {
auto root = datastore->root();
DataSet mds = root.createDataSet("matthieu_prefetch");
CPPUNIT_ASSERT(mds.valid());
Run r = mds.createRun(42);
CPPUNIT_ASSERT(r.valid());
SubRun sr = r.createSubRun(3);
for(unsigned i=0; i < 20; i++) {
Event e = sr.createEvent(i);
CPPUNIT_ASSERT(e.valid());
}
// test begin/end
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=0;
for(auto it = sr.begin(prefetcher); it != sr.end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
CPPUNIT_ASSERT_EQUAL(20, (int)i);
}
// test lower_bound
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=5;
auto it = sr.lower_bound(5, prefetcher);
for(; it != sr.end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
CPPUNIT_ASSERT(i == 20);
}
// test upper_bound
{
AsyncEngine async(*datastore, 1);
Prefetcher prefetcher(*datastore, async);
unsigned i=6;
auto it = sr.upper_bound(5, prefetcher);
for(; it != sr.end(); it++) {
CPPUNIT_ASSERT(it->valid());
CPPUNIT_ASSERT(it->number() == i);
i += 1;
}
CPPUNIT_ASSERT(i == 20);
}
}
......@@ -18,6 +18,7 @@ class SubRunTest : public CppUnit::TestFixture
CPPUNIT_TEST( testLowerUpperBounds );
CPPUNIT_TEST( testAsync );
CPPUNIT_TEST( testPrefetcher );
CPPUNIT_TEST( testAsyncPrefetcher );
CPPUNIT_TEST_SUITE_END();
public:
......@@ -34,6 +35,7 @@ class SubRunTest : public CppUnit::TestFixture
void testLowerUpperBounds();
void testAsync();
void testPrefetcher();
void testAsyncPrefetcher();
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment