comparison UnitTestsSources/FileStorageTests.cpp @ 1124:790ff7a5b3bf

IStorageArea abstraction
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 05 Sep 2014 16:28:34 +0200
parents 6c5a77637b23
children bf67431a7383
comparison
equal deleted inserted replaced
1123:6c5a77637b23 1124:790ff7a5b3bf
61 TEST(FilesystemStorage, Basic) 61 TEST(FilesystemStorage, Basic)
62 { 62 {
63 FilesystemStorage s("UnitTestsStorage"); 63 FilesystemStorage s("UnitTestsStorage");
64 64
65 std::string data = Toolbox::GenerateUuid(); 65 std::string data = Toolbox::GenerateUuid();
66 std::string uid = s.Create(data); 66 std::string uid = s.Create(&data[0], data.size());
67 std::string d; 67 std::string d;
68 s.Read(d, uid); 68 s.Read(d, uid);
69 ASSERT_EQ(d.size(), data.size()); 69 ASSERT_EQ(d.size(), data.size());
70 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); 70 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size()));
71 ASSERT_EQ(s.GetSize(uid), data.size()); 71 ASSERT_EQ(s.GetSize(uid), data.size());
75 { 75 {
76 FilesystemStorage s("UnitTestsStorage"); 76 FilesystemStorage s("UnitTestsStorage");
77 77
78 std::vector<uint8_t> data; 78 std::vector<uint8_t> data;
79 StringToVector(data, Toolbox::GenerateUuid()); 79 StringToVector(data, Toolbox::GenerateUuid());
80 std::string uid = s.Create(data); 80 std::string uid = s.Create(&data[0], data.size());
81 std::string d; 81 std::string d;
82 s.Read(d, uid); 82 s.Read(d, uid);
83 ASSERT_EQ(d.size(), data.size()); 83 ASSERT_EQ(d.size(), data.size());
84 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size())); 84 ASSERT_FALSE(memcmp(&d[0], &data[0], data.size()));
85 ASSERT_EQ(s.GetSize(uid), data.size()); 85 ASSERT_EQ(s.GetSize(uid), data.size());
91 s.Clear(); 91 s.Clear();
92 92
93 std::list<std::string> u; 93 std::list<std::string> u;
94 for (unsigned int i = 0; i < 10; i++) 94 for (unsigned int i = 0; i < 10; i++)
95 { 95 {
96 u.push_back(s.Create(Toolbox::GenerateUuid())); 96 std::string t = Toolbox::GenerateUuid();
97 u.push_back(s.Create(&t[0], t.size()));
97 } 98 }
98 99
99 std::set<std::string> ss; 100 std::set<std::string> ss;
100 s.ListAllFiles(ss); 101 s.ListAllFiles(ss);
101 ASSERT_EQ(10u, ss.size()); 102 ASSERT_EQ(10u, ss.size());