blob: 1caecf1bd60eb738a7b6bc4ce53377c5f0d6b64a [file] [log] [blame]
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/**
* Copyright (c) 2014-2017, Regents of the University of California.
*
* This file is part of NDN repo-ng (Next generation of NDN repository).
* See AUTHORS.md for complete list of repo-ng authors and contributors.
*
* repo-ng is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later version.
*
* repo-ng is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with
* repo-ng, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
*/
#include "storage/repo-storage.hpp"
#include "storage/sqlite-storage.hpp"
#include "../dataset-fixtures.hpp"
#include "../repo-storage-fixture.hpp"
#include <boost/mpl/push_back.hpp>
#include <boost/test/unit_test.hpp>
#include <iostream>
#include <string.h>
namespace repo {
namespace tests {
BOOST_AUTO_TEST_SUITE(RepoStorage)
template<class Dataset>
class Fixture : public Dataset, public RepoStorageFixture
{
};
// Combine CommonDatasets with ComplexSelectorDataset
typedef boost::mpl::push_back<CommonDatasets,
ComplexSelectorsDataset>::type Datasets;
BOOST_FIXTURE_TEST_CASE_TEMPLATE(Bulk, T, Datasets, Fixture<T>)
{
// typedef ComplexSelectorsDataset T;
BOOST_TEST_MESSAGE(T::getName());
// Insert data into repo
for (typename T::DataContainer::iterator i = this->data.begin();
i != this->data.end(); ++i)
{
BOOST_CHECK_EQUAL(this->handle->insertData(**i), true);
}
// check size directly with the storage (repo doesn't have interface yet)
BOOST_CHECK_EQUAL(this->store->size(), static_cast<int64_t>(this->data.size()));
// Read
for (typename T::InterestContainer::iterator i = this->interests.begin();
i != this->interests.end(); ++i)
{
shared_ptr<ndn::Data> dataTest = this->handle->readData(i->first);
BOOST_CHECK_EQUAL(*this->handle->readData(i->first), *i->second);
}
// Remove items
for (typename T::RemovalsContainer::iterator i = this->removals.begin();
i != this->removals.end(); ++i)
{
size_t nRemoved = 0;
BOOST_REQUIRE_NO_THROW(nRemoved = this->handle->deleteData(i->first));
BOOST_CHECK_EQUAL(nRemoved, i->second);
}
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace tests
} // namespace repo