Skip to content

Commit 4a9922f

Browse files
committed
Add make_vector to tests
1 parent dc77c4f commit 4a9922f

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/test/basics/PerfLog_test.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <ripple/protocol/jss.h>
2626
#include <ripple/rpc/impl/Handler.h>
2727
#include <test/jtx/Env.h>
28+
#include <test/jtx/TestHelpers.h>
2829

2930
#include <atomic>
3031
#include <chrono>
@@ -309,9 +310,8 @@ class PerfLog_test : public beast::unit_test::suite
309310

310311
// Get the all the labels we can use for RPC interfaces without
311312
// causing an assert.
312-
std::set<const char*> handlerNames = ripple::RPC::getHandlerNames();
313-
std::vector<char const*> labels(
314-
handlerNames.begin(), handlerNames.end());
313+
std::vector<char const*> labels =
314+
test::jtx::make_vector(ripple::RPC::getHandlerNames());
315315
std::shuffle(labels.begin(), labels.end(), default_prng());
316316

317317
// Get two IDs to associate with each label. Errors tend to happen at

src/test/jtx/TestHelpers.h

+10
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,20 @@
2727
#include <ripple/protocol/jss.h>
2828
#include <test/jtx/Env.h>
2929

30+
#include <ranges>
31+
3032
namespace ripple {
3133
namespace test {
3234
namespace jtx {
3335

36+
// Helper to make vector from iterable
37+
auto
38+
make_vector(auto const& input)
39+
requires std::ranges::range<decltype(input)>
40+
{
41+
return std::vector(std::ranges::begin(input), std::ranges::end(input));
42+
}
43+
3444
// Functions used in debugging
3545
Json::Value
3646
getAccountOffers(Env& env, AccountID const& acct, bool current = false);

src/test/rpc/Handler_test.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,8 @@ class Handler_test : public beast::unit_test::suite
9999
std::random_device dev;
100100
std::ranlux48 prng(dev());
101101

102-
std::set<const char*> handlerNames = RPC::getHandlerNames();
103-
std::vector<const char*> names(
104-
handlerNames.begin(), handlerNames.end());
102+
std::vector<const char*> names =
103+
test::jtx::make_vector(ripple::RPC::getHandlerNames());
105104

106105
std::uniform_int_distribution<std::size_t> distr{0, names.size() - 1};
107106

0 commit comments

Comments
 (0)