blob: 5f3ef22df165c3dc03440556c4b5d06839a00666 [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#include "../storage/sqlite/sqlite-handle.hpp"
8
9#include "sqlite-fixture.hpp"
10#include "dataset-fixtures.hpp"
11
12#include <boost/test/unit_test.hpp>
13
14namespace repo {
15namespace tests {
16
17BOOST_AUTO_TEST_SUITE(SqliteHandle)
18
19template<class Dataset>
20class Fixture : public SqliteFixture, public Dataset
21{
22};
23
24BOOST_FIXTURE_TEST_CASE_TEMPLATE(InsertReadDelete, T, DatasetFixtures, Fixture<T>)
25{
26 BOOST_TEST_MESSAGE(T::getName());
27
28 // Insert
29 for (typename T::DataContainer::iterator i = this->data.begin();
30 i != this->data.end(); ++i) {
31 BOOST_CHECK_EQUAL(this->handle->insertData(**i), true);
32 }
33
34 BOOST_CHECK_EQUAL(this->handle->size(), this->data.size());
35
36 // Read (all items should exist)
37 for (typename T::InterestContainer::iterator i = this->interests.begin();
38 i != this->interests.end(); ++i) {
39 ndn::Data retrievedData;
40 BOOST_REQUIRE_EQUAL(this->handle->readData(i->first, retrievedData), true);
41 BOOST_CHECK_EQUAL(retrievedData, *i->second);
42 }
43
44 // Delete
45 for (typename T::DataContainer::iterator i = this->data.begin();
46 i != this->data.end(); ++i) {
47 BOOST_CHECK_EQUAL(this->handle->deleteData((*i)->getName()), true);
48 }
49
50 // Read (none of the items should exist)
51 for (typename T::InterestContainer::iterator i = this->interests.begin();
52 i != this->interests.end(); ++i) {
53 ndn::Data retrievedData;
54 BOOST_REQUIRE_EQUAL(this->handle->readData(i->first, retrievedData), false);
55 }
56}
57
58BOOST_AUTO_TEST_SUITE_END()
59
60} // namespace tests
61} // namespace repo