Merge branch 'develop' into mvadari/rearch/account

This commit is contained in:
Mayukha Vadari
2026-04-02 16:00:16 -04:00
parent dcdc5e1b52
commit 819d3fcdfc
680 changed files with 7603 additions and 7089 deletions

View File

@@ -52,8 +52,8 @@ TEST(parseStatmRSSkB, standard_format)
// Test standard format: size resident shared text lib data dt
// Assuming 4KB page size: resident=1000 pages = 4000 KB
{
std::string statm = "25365 1000 2377 0 0 5623 0";
long result = parseStatmRSSkB(statm);
std::string const statm = "25365 1000 2377 0 0 5623 0";
long const result = parseStatmRSSkB(statm);
// Note: actual result depends on system page size
// On most systems it's 4KB, so 1000 pages = 4000 KB
EXPECT_GT(result, 0);
@@ -61,57 +61,57 @@ TEST(parseStatmRSSkB, standard_format)
// Test with newline
{
std::string statm = "12345 2000 1234 0 0 3456 0\n";
long result = parseStatmRSSkB(statm);
std::string const statm = "12345 2000 1234 0 0 3456 0\n";
long const result = parseStatmRSSkB(statm);
EXPECT_GT(result, 0);
}
// Test with tabs
{
std::string statm = "12345\t2000\t1234\t0\t0\t3456\t0";
long result = parseStatmRSSkB(statm);
std::string const statm = "12345\t2000\t1234\t0\t0\t3456\t0";
long const result = parseStatmRSSkB(statm);
EXPECT_GT(result, 0);
}
// Test zero resident pages
{
std::string statm = "25365 0 2377 0 0 5623 0";
long result = parseStatmRSSkB(statm);
std::string const statm = "25365 0 2377 0 0 5623 0";
long const result = parseStatmRSSkB(statm);
EXPECT_EQ(result, 0);
}
// Test with extra whitespace
{
std::string statm = " 25365 1000 2377 ";
long result = parseStatmRSSkB(statm);
std::string const statm = " 25365 1000 2377 ";
long const result = parseStatmRSSkB(statm);
EXPECT_GT(result, 0);
}
// Test empty string
{
std::string statm;
long result = parseStatmRSSkB(statm);
std::string const statm;
long const result = parseStatmRSSkB(statm);
EXPECT_EQ(result, -1);
}
// Test malformed data (only one field)
{
std::string statm = "25365";
long result = parseStatmRSSkB(statm);
std::string const statm = "25365";
long const result = parseStatmRSSkB(statm);
EXPECT_EQ(result, -1);
}
// Test malformed data (non-numeric)
{
std::string statm = "abc def ghi";
long result = parseStatmRSSkB(statm);
std::string const statm = "abc def ghi";
long const result = parseStatmRSSkB(statm);
EXPECT_EQ(result, -1);
}
// Test malformed data (second field non-numeric)
{
std::string statm = "25365 abc 2377";
long result = parseStatmRSSkB(statm);
std::string const statm = "25365 abc 2377";
long const result = parseStatmRSSkB(statm);
EXPECT_EQ(result, -1);
}
}
@@ -119,9 +119,9 @@ TEST(parseStatmRSSkB, standard_format)
TEST(mallocTrim, without_debug_logging)
{
beast::Journal journal{beast::Journal::getNullSink()};
beast::Journal const journal{beast::Journal::getNullSink()};
MallocTrimReport report = mallocTrim("without_debug", journal);
MallocTrimReport const report = mallocTrim("without_debug", journal);
#if defined(__GLIBC__) && BOOST_OS_LINUX
EXPECT_EQ(report.supported, true);
@@ -142,8 +142,8 @@ TEST(mallocTrim, without_debug_logging)
TEST(mallocTrim, empty_tag)
{
beast::Journal journal{beast::Journal::getNullSink()};
MallocTrimReport report = mallocTrim("", journal);
beast::Journal const journal{beast::Journal::getNullSink()};
MallocTrimReport const report = mallocTrim("", journal);
#if defined(__GLIBC__) && BOOST_OS_LINUX
EXPECT_EQ(report.supported, true);
@@ -171,9 +171,9 @@ TEST(mallocTrim, with_debug_logging)
};
DebugSink sink;
beast::Journal journal{sink};
beast::Journal const journal{sink};
MallocTrimReport report = mallocTrim("debug_test", journal);
MallocTrimReport const report = mallocTrim("debug_test", journal);
#if defined(__GLIBC__) && BOOST_OS_LINUX
EXPECT_EQ(report.supported, true);
@@ -192,12 +192,12 @@ TEST(mallocTrim, with_debug_logging)
TEST(mallocTrim, repeated_calls)
{
beast::Journal journal{beast::Journal::getNullSink()};
beast::Journal const journal{beast::Journal::getNullSink()};
// Call malloc_trim multiple times to ensure it's safe
for (int i = 0; i < 5; ++i)
{
MallocTrimReport report = mallocTrim("iteration_" + std::to_string(i), journal);
MallocTrimReport const report = mallocTrim("iteration_" + std::to_string(i), journal);
#if defined(__GLIBC__) && BOOST_OS_LINUX
EXPECT_EQ(report.supported, true);

View File

@@ -183,7 +183,7 @@ TEST_F(MutexConstCorrectnessTest, non_const_allows_modification)
TEST_F(MutexConstCorrectnessTest, const_reference_provides_const_access)
{
Mutex<std::vector<int>> m({1, 2, 3, 4, 5, 6});
Mutex<std::vector<int>> const m({1, 2, 3, 4, 5, 6});
Mutex<std::vector<int>> const& const_ref = m;
auto lock = const_ref.lock();
static_assert(std::is_const_v<std::remove_reference_t<decltype(*lock)>>);
@@ -225,7 +225,7 @@ struct MutexSharedMutexTest : ::testing::Test
TEST_F(MutexSharedMutexTest, shared_lock_for_const_access)
{
Mutex<int, std::shared_mutex> m(100);
Mutex<int, std::shared_mutex> const m(100);
Mutex<int, std::shared_mutex> const& const_ref = m;
auto lock = const_ref.lock<std::shared_lock>();
EXPECT_EQ(*lock, 100);

View File

@@ -10,7 +10,7 @@ TEST(scope, scope_exit)
// unless release() is called
int i = 0;
{
scope_exit x{[&i]() { i = 1; }};
scope_exit const x{[&i]() { i = 1; }};
}
EXPECT_EQ(i, 1);
{
@@ -32,7 +32,7 @@ TEST(scope, scope_exit)
{
try
{
scope_exit x{[&i]() { i = 5; }};
scope_exit const x{[&i]() { i = 5; }};
throw 1;
}
catch (...) // NOLINT(bugprone-empty-catch)
@@ -60,7 +60,7 @@ TEST(scope, scope_fail)
// if an exception is unwinding, unless release() is called
int i = 0;
{
scope_fail x{[&i]() { i = 1; }};
scope_fail const x{[&i]() { i = 1; }};
}
EXPECT_EQ(i, 0);
{
@@ -82,7 +82,7 @@ TEST(scope, scope_fail)
{
try
{
scope_fail x{[&i]() { i = 5; }};
scope_fail const x{[&i]() { i = 5; }};
throw 1;
}
catch (...) // NOLINT(bugprone-empty-catch)
@@ -110,7 +110,7 @@ TEST(scope, scope_success)
// if an exception is not unwinding, unless release() is called
int i = 0;
{
scope_success x{[&i]() { i = 1; }};
scope_success const x{[&i]() { i = 1; }};
}
EXPECT_EQ(i, 1);
{
@@ -132,7 +132,7 @@ TEST(scope, scope_success)
{
try
{
scope_success x{[&i]() { i = 5; }};
scope_success const x{[&i]() { i = 5; }};
throw 1;
}
catch (...) // NOLINT(bugprone-empty-catch)

View File

@@ -147,7 +147,7 @@ TEST(tagged_integer, increment_decrement_operators)
TEST(tagged_integer, arithmetic_operators)
{
TagInt a{-2};
TagInt const a{-2};
EXPECT_EQ(+a, TagInt{-2});
EXPECT_EQ(-a, TagInt{2});
EXPECT_EQ(TagInt{-3} + TagInt{4}, TagInt{1});

View File

@@ -38,7 +38,7 @@ TEST(json_value, construct_and_compare_Json_StaticString)
EXPECT_EQ(test1, test2);
EXPECT_NE(test1, test3);
std::string str{sample};
std::string const str{sample};
EXPECT_EQ(str, test2);
EXPECT_NE(str, test3);
EXPECT_EQ(test2, str);
@@ -52,7 +52,7 @@ TEST(json_value, different_types)
auto testCopy = [](Json::ValueType typ) {
Json::Value val{typ};
Json::Value cpy{val};
Json::Value const cpy{val};
EXPECT_EQ(val.type(), typ);
EXPECT_EQ(cpy.type(), typ);
return val;
@@ -135,7 +135,7 @@ TEST(json_value, different_types)
{
Json::Value const staticStrV{staticStr};
{
Json::Value cpy{staticStrV};
Json::Value const cpy{staticStrV};
EXPECT_EQ(staticStrV.type(), Json::stringValue);
EXPECT_EQ(cpy.type(), Json::stringValue);
}
@@ -588,13 +588,13 @@ TEST(json_value, bad_json)
TEST(json_value, edge_cases)
{
std::uint32_t max_uint = std::numeric_limits<std::uint32_t>::max();
std::int32_t max_int = std::numeric_limits<std::int32_t>::max();
std::int32_t min_int = std::numeric_limits<std::int32_t>::min();
std::uint32_t const max_uint = std::numeric_limits<std::uint32_t>::max();
std::int32_t const max_int = std::numeric_limits<std::int32_t>::max();
std::int32_t const min_int = std::numeric_limits<std::int32_t>::min();
std::uint32_t a_uint = max_uint - 1978;
std::int32_t a_large_int = max_int - 1978;
std::int32_t a_small_int = min_int + 1978;
std::uint32_t const a_uint = max_uint - 1978;
std::int32_t const a_large_int = max_int - 1978;
std::int32_t const a_small_int = min_int + 1978;
{
std::string json = "{\"max_uint\":" + std::to_string(max_uint);
@@ -628,7 +628,7 @@ TEST(json_value, edge_cases)
EXPECT_LT(j1["a_small_int"], a_uint);
}
std::uint64_t overflow = std::uint64_t(max_uint) + 1;
std::uint64_t const overflow = std::uint64_t(max_uint) + 1;
{
std::string json = "{\"overflow\":";
json += std::to_string(overflow);
@@ -640,7 +640,7 @@ TEST(json_value, edge_cases)
EXPECT_FALSE(r2.parse(json, j2));
}
std::int64_t underflow = std::int64_t(min_int) - 1;
std::int64_t const underflow = std::int64_t(min_int) - 1;
{
std::string json = "{\"underflow\":";
json += std::to_string(underflow);
@@ -739,7 +739,7 @@ TEST(json_value, copy)
EXPECT_TRUE(v1.isDouble());
EXPECT_EQ(v1.asDouble(), 2.5);
Json::Value v2 = v1;
Json::Value const v2 = v1;
EXPECT_TRUE(v1.isDouble());
EXPECT_EQ(v1.asDouble(), 2.5);
EXPECT_TRUE(v2.isDouble());
@@ -819,7 +819,7 @@ TEST(json_value, comparisons)
b["a"] = Json::Int(-1);
testGreaterThan("negative");
Json::Int big = std::numeric_limits<int>::max();
Json::Int const big = std::numeric_limits<int>::max();
Json::UInt bigger = big;
bigger++;
@@ -859,7 +859,7 @@ TEST(json_value, conversions)
// TODO: What's the thinking here?
{
// null
Json::Value val;
Json::Value const val;
EXPECT_TRUE(val.isNull());
// val.asCString() should trigger an assertion failure
EXPECT_EQ(val.asString(), "");
@@ -880,7 +880,7 @@ TEST(json_value, conversions)
}
{
// int
Json::Value val = -1234;
Json::Value const val = -1234;
EXPECT_TRUE(val.isInt());
// val.asCString() should trigger an assertion failure
EXPECT_EQ(val.asString(), "-1234");
@@ -901,7 +901,7 @@ TEST(json_value, conversions)
}
{
// uint
Json::Value val = 1234U;
Json::Value const val = 1234U;
EXPECT_TRUE(val.isUInt());
// val.asCString() should trigger an assertion failure
EXPECT_EQ(val.asString(), "1234");
@@ -922,7 +922,7 @@ TEST(json_value, conversions)
}
{
// real
Json::Value val = 2.0;
Json::Value const val = 2.0;
EXPECT_TRUE(val.isDouble());
// val.asCString() should trigger an assertion failure
EXPECT_TRUE(std::regex_match(val.asString(), std::regex("^2\\.0*$")));
@@ -943,7 +943,7 @@ TEST(json_value, conversions)
}
{
// numeric string
Json::Value val = "54321";
Json::Value const val = "54321";
EXPECT_TRUE(val.isString());
EXPECT_EQ(strcmp(val.asCString(), "54321"), 0);
EXPECT_EQ(val.asString(), "54321");
@@ -964,7 +964,7 @@ TEST(json_value, conversions)
}
{
// non-numeric string
Json::Value val(Json::stringValue);
Json::Value const val(Json::stringValue);
EXPECT_TRUE(val.isString());
EXPECT_EQ(val.asCString(), nullptr);
EXPECT_EQ(val.asString(), "");
@@ -985,7 +985,7 @@ TEST(json_value, conversions)
}
{
// bool false
Json::Value val = false;
Json::Value const val = false;
EXPECT_TRUE(val.isBool());
// val.asCString() should trigger an assertion failure
EXPECT_EQ(val.asString(), "false");
@@ -1006,7 +1006,7 @@ TEST(json_value, conversions)
}
{
// bool true
Json::Value val = true;
Json::Value const val = true;
EXPECT_TRUE(val.isBool());
// val.asCString() should trigger an assertion failure
EXPECT_EQ(val.asString(), "true");
@@ -1027,7 +1027,7 @@ TEST(json_value, conversions)
}
{
// array type
Json::Value val(Json::arrayValue);
Json::Value const val(Json::arrayValue);
EXPECT_TRUE(val.isArray());
// val.asCString should trigger an assertion failure
EXPECT_THROW(val.asString(), Json::error);
@@ -1048,7 +1048,7 @@ TEST(json_value, conversions)
}
{
// object type
Json::Value val(Json::objectValue);
Json::Value const val(Json::objectValue);
EXPECT_TRUE(val.isObject());
// val.asCString should trigger an assertion failure
EXPECT_THROW(val.asString(), Json::error);

View File

@@ -267,7 +267,7 @@ protected:
TEST_F(HTTPClientTest, case_insensitive_content_length)
{
// Test different cases of Content-Length header
std::vector<std::string> headerCases = {
std::vector<std::string> const headerCases = {
"Content-Length", // Standard case
"content-length", // Lowercase - this tests the regex icase fix
"CONTENT-LENGTH", // Uppercase
@@ -278,7 +278,7 @@ TEST_F(HTTPClientTest, case_insensitive_content_length)
for (auto const& headerName : headerCases)
{
TestHTTPServer server;
std::string testBody = "Hello World!";
std::string const testBody = "Hello World!";
server.setResponseBody(testBody);
server.setHeader(headerName, std::to_string(testBody.size()));
@@ -287,7 +287,7 @@ TEST_F(HTTPClientTest, case_insensitive_content_length)
std::string resultData;
boost::system::error_code resultError;
bool testCompleted =
bool const testCompleted =
runHTTPTest(server, "/test", completed, resultStatus, resultData, resultError);
// Verify results
EXPECT_TRUE(testCompleted);
@@ -300,7 +300,7 @@ TEST_F(HTTPClientTest, case_insensitive_content_length)
TEST_F(HTTPClientTest, basic_http_request)
{
TestHTTPServer server;
std::string testBody = "Test response body";
std::string const testBody = "Test response body";
server.setResponseBody(testBody);
server.setHeader("Content-Type", "text/plain");
@@ -309,7 +309,7 @@ TEST_F(HTTPClientTest, basic_http_request)
std::string resultData;
boost::system::error_code resultError;
bool testCompleted =
bool const testCompleted =
runHTTPTest(server, "/basic", completed, resultStatus, resultData, resultError);
EXPECT_TRUE(testCompleted);
@@ -329,7 +329,7 @@ TEST_F(HTTPClientTest, empty_response)
std::string resultData;
boost::system::error_code resultError;
bool testCompleted =
bool const testCompleted =
runHTTPTest(server, "/empty", completed, resultStatus, resultData, resultError);
EXPECT_TRUE(testCompleted);
@@ -340,7 +340,7 @@ TEST_F(HTTPClientTest, empty_response)
TEST_F(HTTPClientTest, different_status_codes)
{
std::vector<unsigned int> statusCodes = {200, 404, 500};
std::vector<unsigned int> const statusCodes = {200, 404, 500};
for (auto status : statusCodes)
{
@@ -353,7 +353,7 @@ TEST_F(HTTPClientTest, different_status_codes)
std::string resultData;
boost::system::error_code resultError;
bool testCompleted =
bool const testCompleted =
runHTTPTest(server, "/status", completed, resultStatus, resultData, resultError);
EXPECT_TRUE(testCompleted);

View File

@@ -0,0 +1,3 @@
# This disables all checks for this directory and its subdirectories
Checks: "-*"
InheritParentConfig: false

View File

@@ -1,70 +0,0 @@
#include <xrpl/protocol/MPTAmount.h>
#include <xrpl/protocol/MPTIssue.h>
#include <xrpl/protocol/STAmount.h>
#include <xrpl/protocol_autogen/STObjectValidation.h>
#include <gtest/gtest.h>
namespace xrpl {
TEST(STObjectValidation, validate_required_field)
{
SOTemplate format{{sfFlags, soeREQUIRED}};
STObject obj(sfGeneric);
obj.setFieldU32(sfFlags, 0);
EXPECT_TRUE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_missing_required_field)
{
SOTemplate format{{sfFlags, soeREQUIRED}};
STObject obj(sfGeneric);
EXPECT_FALSE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_optional_field)
{
SOTemplate format{{sfFlags, soeOPTIONAL}};
STObject obj(sfGeneric);
obj.setFieldU32(sfFlags, 0);
EXPECT_TRUE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_missing_optional_field)
{
SOTemplate format{{sfFlags, soeOPTIONAL}};
STObject obj(sfGeneric);
EXPECT_TRUE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_mpt_amount_supported)
{
SOTemplate format{{sfAmount, soeREQUIRED, soeMPTSupported}};
STObject obj(sfGeneric);
obj.setFieldAmount(sfAmount, STAmount{MPTAmount{Number{1}}, MPTIssue{}});
EXPECT_TRUE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_mpt_amount_not_supported)
{
SOTemplate format{{sfAmount, soeREQUIRED, soeMPTNotSupported}};
STObject obj(sfGeneric);
obj.setFieldAmount(sfAmount, STAmount{MPTAmount{Number{1}}, MPTIssue{}});
EXPECT_FALSE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_mpt_issue_supported)
{
SOTemplate format{{sfAsset, soeREQUIRED, soeMPTSupported}};
STObject obj(sfGeneric);
obj.setFieldIssue(sfAsset, STIssue{sfAsset, MPTIssue{}});
EXPECT_TRUE(protocol_autogen::validateSTObject(obj, format));
}
TEST(STObjectValidation, validate_mpt_issue_not_supported)
{
SOTemplate format{{sfAsset, soeREQUIRED, soeMPTNotSupported}};
STObject obj(sfGeneric);
obj.setFieldIssue(sfAsset, STIssue{sfAsset, MPTIssue{}});
EXPECT_FALSE(protocol_autogen::validateSTObject(obj, format));
}
} // namespace xrpl

View File

@@ -1,8 +0,0 @@
#include <gtest/gtest.h>
int
main(int argc, char** argv)
{
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}