mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-19 13:03:36 +00:00
Format all C++ and Java code via clang-format
Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
@@ -4,8 +4,8 @@
|
||||
#include "coding/varint.hpp"
|
||||
|
||||
#include "base/logging.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
#include "base/scope_guard.hpp"
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
#include "std/target_os.hpp"
|
||||
|
||||
@@ -56,7 +56,7 @@ UNIT_TEST(FilesContainer_Smoke)
|
||||
}
|
||||
|
||||
// append to container
|
||||
uint32_t const arrAppend[] = { 888, 777, 666 };
|
||||
uint32_t const arrAppend[] = {888, 777, 666};
|
||||
for (size_t i = 0; i < ARRAY_SIZE(arrAppend); ++i)
|
||||
{
|
||||
{
|
||||
@@ -82,12 +82,12 @@ UNIT_TEST(FilesContainer_Smoke)
|
||||
|
||||
namespace
|
||||
{
|
||||
void CheckInvariant(FilesContainerR & reader, string const & tag, int64_t test)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(tag);
|
||||
TEST_EQUAL(test, ReadPrimitiveFromPos<int64_t>(r, 0), ());
|
||||
}
|
||||
void CheckInvariant(FilesContainerR & reader, string const & tag, int64_t test)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(tag);
|
||||
TEST_EQUAL(test, ReadPrimitiveFromPos<int64_t>(r, 0), ());
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FilesContainer_Shared)
|
||||
{
|
||||
@@ -147,43 +147,41 @@ UNIT_TEST(FilesContainer_Shared)
|
||||
|
||||
namespace
|
||||
{
|
||||
void ReplaceInContainer(string const & fName,
|
||||
char const * key, char const * value)
|
||||
void ReplaceInContainer(string const & fName, char const * key, char const * value)
|
||||
{
|
||||
FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING);
|
||||
auto w = writer.GetWriter(key);
|
||||
w->Write(value, strlen(value));
|
||||
}
|
||||
|
||||
void CheckContainer(string const & fName, char const * key[], char const * value[], size_t count)
|
||||
{
|
||||
FilesContainerR reader(fName);
|
||||
LOG(LINFO, ("Size=", reader.GetFileSize()));
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
FilesContainerW writer(fName, FileWriter::OP_WRITE_EXISTING);
|
||||
auto w = writer.GetWriter(key);
|
||||
w->Write(value, strlen(value));
|
||||
}
|
||||
FilesContainerR::TReader r = reader.GetReader(key[i]);
|
||||
|
||||
void CheckContainer(string const & fName,
|
||||
char const * key[], char const * value[], size_t count)
|
||||
{
|
||||
FilesContainerR reader(fName);
|
||||
LOG(LINFO, ("Size=", reader.GetFileSize()));
|
||||
size_t const szBuffer = 100;
|
||||
size_t const szS = strlen(value[i]);
|
||||
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
FilesContainerR::TReader r = reader.GetReader(key[i]);
|
||||
char s[szBuffer] = {0};
|
||||
ASSERT_LESS(szS, szBuffer, ());
|
||||
r.Read(0, s, szS);
|
||||
|
||||
size_t const szBuffer = 100;
|
||||
size_t const szS = strlen(value[i]);
|
||||
|
||||
char s[szBuffer] = { 0 };
|
||||
ASSERT_LESS ( szS, szBuffer, () );
|
||||
r.Read(0, s, szS);
|
||||
|
||||
TEST(strcmp(value[i], s) == 0, (s));
|
||||
}
|
||||
TEST(strcmp(value[i], s) == 0, (s));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
UNIT_TEST(FilesContainer_RewriteExisting)
|
||||
{
|
||||
string const fName = "files_container.tmp";
|
||||
FileWriter::DeleteFileX(fName);
|
||||
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const * value[] = { "prolog", "data", "epilog" };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
char const * value[] = {"prolog", "data", "epilog"};
|
||||
|
||||
// fill container
|
||||
{
|
||||
@@ -199,19 +197,19 @@ UNIT_TEST(FilesContainer_RewriteExisting)
|
||||
// re-write middle file in container
|
||||
char const * buffer1 = "xxxxxxx";
|
||||
ReplaceInContainer(fName, key[1], buffer1);
|
||||
char const * value1[] = { value[0], buffer1, value[2] };
|
||||
char const * value1[] = {value[0], buffer1, value[2]};
|
||||
CheckContainer(fName, key, value1, 3);
|
||||
|
||||
// re-write end file in container
|
||||
char const * buffer2 = "yyyyyyyyyyyyyy";
|
||||
ReplaceInContainer(fName, key[2], buffer2);
|
||||
char const * value2[] = { value[0], buffer1, buffer2 };
|
||||
char const * value2[] = {value[0], buffer1, buffer2};
|
||||
CheckContainer(fName, key, value2, 3);
|
||||
|
||||
// re-write end file in container once again
|
||||
char const * buffer3 = "zzz";
|
||||
ReplaceInContainer(fName, key[2], buffer3);
|
||||
char const * value3[] = { value[0], buffer1, buffer3 };
|
||||
char const * value3[] = {value[0], buffer1, buffer3};
|
||||
CheckContainer(fName, key, value3, 3);
|
||||
|
||||
FileWriter::DeleteFileX(fName);
|
||||
@@ -334,7 +332,7 @@ UNIT_TEST(FilesMappingContainer_MoveHandle)
|
||||
UNIT_TEST(FilesMappingContainer_Smoke)
|
||||
{
|
||||
string const fName = "files_container.tmp";
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
uint32_t const count = 1000000;
|
||||
|
||||
// fill container
|
||||
@@ -385,9 +383,9 @@ UNIT_TEST(FilesMappingContainer_PageSize)
|
||||
#endif
|
||||
LOG(LINFO, ("Page size:", pageSize));
|
||||
|
||||
char const * key[] = { "3", "2", "1" };
|
||||
char const byte[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g' };
|
||||
size_t count[] = { pageSize-1, pageSize, pageSize+1 };
|
||||
char const * key[] = {"3", "2", "1"};
|
||||
char const byte[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g'};
|
||||
size_t count[] = {pageSize - 1, pageSize, pageSize + 1};
|
||||
size_t const sz = ARRAY_SIZE(key);
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user