mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-27 15:15:52 +00:00
style: clang-tidy auto fixes (#2783)
This commit is contained in:
committed by
GitHub
parent
20e7e275cf
commit
1ef7ec3464
@@ -265,8 +265,8 @@ LedgerCache::saveToFile(std::string const& path) const
|
||||
}
|
||||
|
||||
impl::LedgerCacheFile file{path};
|
||||
std::unique_lock lock{mtx_};
|
||||
impl::LedgerCacheFile::DataView data{.latestSeq = latestSeq_, .map = map_, .deleted = deleted_};
|
||||
std::unique_lock const lock{mtx_};
|
||||
impl::LedgerCacheFile::DataView const data{.latestSeq = latestSeq_, .map = map_, .deleted = deleted_};
|
||||
return file.write(data);
|
||||
}
|
||||
|
||||
@@ -279,7 +279,7 @@ LedgerCache::loadFromFile(std::string const& path, uint32_t minLatestSequence)
|
||||
return std::unexpected(std::move(data).error());
|
||||
}
|
||||
auto [latestSeq, map, deleted] = std::move(data).value();
|
||||
std::unique_lock lock{mtx_};
|
||||
std::unique_lock const lock{mtx_};
|
||||
latestSeq_ = latestSeq;
|
||||
map_ = std::move(map);
|
||||
deleted_ = std::move(deleted);
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "util/TmpFile.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
@@ -35,7 +34,7 @@ struct InputFileTest : ::testing::Test {};
|
||||
TEST_F(InputFileTest, ConstructorWithValidFile)
|
||||
{
|
||||
auto const tmpFile = TmpFile{"Hello, World!"};
|
||||
InputFile inputFile(tmpFile.path);
|
||||
InputFile const inputFile(tmpFile.path);
|
||||
|
||||
EXPECT_TRUE(inputFile.isOpen());
|
||||
}
|
||||
@@ -66,7 +65,7 @@ TEST_F(InputFileTest, ReadRawFromFile)
|
||||
|
||||
TEST_F(InputFileTest, ReadRawFromFilePartial)
|
||||
{
|
||||
std::string content = "Hello, World!";
|
||||
std::string const content = "Hello, World!";
|
||||
auto tmpFile = TmpFile{content};
|
||||
InputFile inputFile(tmpFile.path);
|
||||
|
||||
@@ -87,7 +86,7 @@ TEST_F(InputFileTest, ReadRawFromFilePartial)
|
||||
|
||||
TEST_F(InputFileTest, ReadRawAfterEnd)
|
||||
{
|
||||
std::string content = "Test";
|
||||
std::string const content = "Test";
|
||||
auto tmpFile = TmpFile{content};
|
||||
InputFile inputFile(tmpFile.path);
|
||||
|
||||
@@ -119,7 +118,7 @@ TEST_F(InputFileTest, ReadTemplateMethod)
|
||||
ASSERT_TRUE(inputFile.isOpen());
|
||||
|
||||
std::uint32_t value{0};
|
||||
bool success = inputFile.read(value);
|
||||
bool const success = inputFile.read(value);
|
||||
|
||||
EXPECT_TRUE(success);
|
||||
// Note: The actual value depends on endianness
|
||||
@@ -151,7 +150,7 @@ TEST_F(InputFileTest, ReadFromEmptyFile)
|
||||
TEST_F(InputFileTest, HashOfEmptyFile)
|
||||
{
|
||||
auto tmpFile = TmpFile::empty();
|
||||
InputFile inputFile(tmpFile.path);
|
||||
InputFile const inputFile(tmpFile.path);
|
||||
|
||||
ASSERT_TRUE(inputFile.isOpen());
|
||||
EXPECT_EQ(inputFile.hash(), util::sha256sum(""));
|
||||
|
||||
@@ -212,28 +212,28 @@ struct LedgerCacheFileTestBase : ::testing::Test {
|
||||
case CorruptionType::CorruptedSeparator1:
|
||||
file.seekp(offsets.separator1Offset);
|
||||
{
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
case CorruptionType::CorruptedSeparator2:
|
||||
file.seekp(offsets.separator2Offset);
|
||||
{
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
case CorruptionType::CorruptedSeparator3:
|
||||
file.seekp(offsets.separator3Offset);
|
||||
{
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
case CorruptionType::MapKeyCorrupted:
|
||||
if (!offsets.mapEntries.empty()) {
|
||||
file.seekp(offsets.mapEntries[0].keyOffset);
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
@@ -254,14 +254,14 @@ struct LedgerCacheFileTestBase : ::testing::Test {
|
||||
case CorruptionType::MapBlobDataCorrupted:
|
||||
if (!offsets.mapEntries.empty() && !dataView.map.begin()->second.blob.empty()) {
|
||||
file.seekp(offsets.mapEntries[0].blobDataOffset);
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
case CorruptionType::DeletedKeyCorrupted:
|
||||
if (!offsets.deletedEntries.empty()) {
|
||||
file.seekp(offsets.deletedEntries[0].keyOffset);
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
@@ -282,7 +282,7 @@ struct LedgerCacheFileTestBase : ::testing::Test {
|
||||
case CorruptionType::DeletedBlobDataCorrupted:
|
||||
if (!offsets.deletedEntries.empty() && !dataView.deleted.begin()->second.blob.empty()) {
|
||||
file.seekp(offsets.deletedEntries[0].blobDataOffset);
|
||||
char corruptByte = static_cast<char>(0xFF);
|
||||
char const corruptByte = static_cast<char>(0xFF);
|
||||
file.write(&corruptByte, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "util/TmpFile.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@@ -48,14 +47,14 @@ struct OutputFileTest : ::testing::Test {
|
||||
|
||||
TEST_F(OutputFileTest, ConstructorOpensFile)
|
||||
{
|
||||
OutputFile file(tmpFile.path);
|
||||
OutputFile const file(tmpFile.path);
|
||||
EXPECT_TRUE(file.isOpen());
|
||||
}
|
||||
|
||||
TEST_F(OutputFileTest, NonExistingFile)
|
||||
{
|
||||
std::string const invalidPath = "/invalid/nonexistent/directory/file.dat";
|
||||
OutputFile file(invalidPath);
|
||||
OutputFile const file(invalidPath);
|
||||
EXPECT_FALSE(file.isOpen());
|
||||
}
|
||||
|
||||
@@ -107,7 +106,7 @@ TEST_F(OutputFileTest, WriteRawData)
|
||||
file.writeRaw(testData.data(), testData.size());
|
||||
}
|
||||
|
||||
std::string contents = readFileContents();
|
||||
std::string const contents = readFileContents();
|
||||
EXPECT_EQ(contents, testData);
|
||||
}
|
||||
|
||||
@@ -125,13 +124,13 @@ TEST_F(OutputFileTest, WriteMultipleChunks)
|
||||
file.writeRaw(chunk3.data(), chunk3.size());
|
||||
}
|
||||
|
||||
std::string contents = readFileContents();
|
||||
std::string const contents = readFileContents();
|
||||
EXPECT_EQ(contents, chunk1 + chunk2 + chunk3);
|
||||
}
|
||||
|
||||
TEST_F(OutputFileTest, HashOfEmptyFile)
|
||||
{
|
||||
OutputFile file(tmpFile.path);
|
||||
OutputFile const file(tmpFile.path);
|
||||
ASSERT_TRUE(file.isOpen());
|
||||
|
||||
// Hash of empty file should match SHA256 of empty string
|
||||
|
||||
Reference in New Issue
Block a user