Scroom  0.14
blob-tests.cc File Reference
#include <cstring>
#include <list>
#include <boost/test/unit_test.hpp>
#include <scroom/memoryblobs.hh>
Include dependency graph for blob-tests.cc:

Functions

 BOOST_AUTO_TEST_CASE (blobs_retain_their_data)
 
 BOOST_AUTO_TEST_CASE (blobs_can_be_updated)
 
 BOOST_AUTO_TEST_CASE (blobs_can_be_initialized)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( blobs_can_be_initialized  )
112 {
113  const size_t blobSize = 4096;
114  const size_t blockCount = 16;
115  const size_t blockSize = 64;
116  const uint8_t value = 25;
117 
118  PageProvider::Ptr provider = PageProvider::create(blockCount, blockSize);
119 
120  Blob::Ptr const b = Blob::create(provider, blobSize);
121  provider.reset();
122 
123  RawPageData::Ptr const raw = b->initialize(value);
124 
125  uint8_t expected[blobSize];
126  memset(expected, value, blobSize);
127 
128  BOOST_CHECK(!memcmp(expected, raw.get(), blobSize));
129 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( blobs_can_be_updated  )
62 {
63  const size_t blobSize = 16 * 1024;
64  const size_t blobCount = 16;
65  const size_t blockCount = 16;
66  const size_t blockSize = 64;
67 
68  PageProvider::Ptr provider = PageProvider::create(blockCount, blockSize);
69 
70  std::list<Blob::Ptr> blobList;
71 
72  for(size_t i = 0; i < blobCount; i++)
73  {
74  blobList.push_back(Blob::create(provider, blobSize));
75  }
76  provider.reset();
77 
78  uint8_t data = 0;
79  for(const Blob::Ptr& b: blobList)
80  {
81  RawPageData::Ptr const raw = b->get();
82  BOOST_REQUIRE(raw.get());
83 
84  memset(raw.get(), data, blobSize);
85  data++;
86  }
87 
88  data = 0;
89  for(const Blob::Ptr& b: blobList)
90  {
91  RawPageData::Ptr const raw = b->get();
92  BOOST_REQUIRE(raw.get());
93 
94  memset(raw.get(), 255 - data, blobSize);
95  data++;
96  }
97 
98  data = 0;
99  uint8_t expected[blobSize];
100  for(const Blob::Ptr& b: blobList)
101  {
102  RawPageData::ConstPtr const raw = b->getConst();
103  BOOST_REQUIRE(raw.get());
104 
105  memset(expected, 255 - data, blobSize);
106  BOOST_CHECK(!memcmp(expected, raw.get(), blobSize));
107  data++;
108  }
109 }
Here is the call graph for this function:

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( blobs_retain_their_data  )
22 {
23  const size_t blobSize = 16 * 1024;
24  const size_t blobCount = 16;
25  const size_t blockCount = 16;
26  const size_t blockSize = 64;
27 
28  PageProvider::Ptr provider = PageProvider::create(blockCount, blockSize);
29 
30  std::list<Blob::Ptr> blobList;
31 
32  for(size_t i = 0; i < blobCount; i++)
33  {
34  blobList.push_back(Blob::create(provider, blobSize));
35  }
36  provider.reset();
37 
38  uint8_t data = 0;
39  for(const Blob::Ptr& b: blobList)
40  {
41  RawPageData::Ptr const raw = b->get();
42  BOOST_REQUIRE(raw.get());
43 
44  memset(raw.get(), data, blobSize);
45  data++;
46  }
47 
48  data = 0;
49  uint8_t expected[blobSize];
50  for(const Blob::Ptr& b: blobList)
51  {
52  RawPageData::ConstPtr const raw = b->getConst();
53  BOOST_REQUIRE(raw.get());
54 
55  memset(expected, data, blobSize);
56  BOOST_CHECK(!memcmp(expected, raw.get(), blobSize));
57  data++;
58  }
59 }
Here is the call graph for this function:
Scroom::MemoryBlobs::PageProvider::Ptr
boost::shared_ptr< PageProvider > Ptr
Definition: memoryblobs.hh:41
Scroom::MemoryBlobs::RawPageData::ConstPtr
boost::shared_ptr< const uint8_t > ConstPtr
Definition: memoryblobs.hh:28
Scroom::MemoryBlobs::Blob::Ptr
boost::shared_ptr< Blob > Ptr
Definition: memoryblobs.hh:78
Scroom::MemoryBlobs::RawPageData::Ptr
boost::shared_ptr< uint8_t > Ptr
Definition: memoryblobs.hh:27
BOOST_REQUIRE
BOOST_REQUIRE(originalColormap)
b
static void b(const B::Ptr &)
Definition: gtkhelper-tests.cc:32
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175