diff --git a/tests/common/util/NameGenerator.hpp b/tests/common/util/NameGenerator.hpp new file mode 100644 index 000000000..c90df7f88 --- /dev/null +++ b/tests/common/util/NameGenerator.hpp @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +/* + This file is part of clio: https://github.com/XRPLF/clio + Copyright (c) 2024, the clio developers. + + Permission to use, copy, modify, and distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +#pragma once + +#include + +namespace tests::util { + +static auto const NameGenerator = [](auto const& info) { return info.param.testName; }; + +} // namespace tests::util diff --git a/tests/unit/rpc/JsonBoolTests.cpp b/tests/unit/rpc/JsonBoolTests.cpp index 63673121d..0b7275094 100644 --- a/tests/unit/rpc/JsonBoolTests.cpp +++ b/tests/unit/rpc/JsonBoolTests.cpp @@ -17,6 +17,7 @@ */ //============================================================================== #include "rpc/common/JsonBool.hpp" +#include "util/NameGenerator.hpp" #include #include @@ -37,16 +38,6 @@ struct JsonBoolTestsCaseBundle { class JsonBoolTests : public TestWithParam { public: - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; - static auto generateTestValuesForParametersTest() { @@ -72,7 +63,7 @@ INSTANTIATE_TEST_CASE_P( JsonBoolCheckGroup, JsonBoolTests, ValuesIn(JsonBoolTests::generateTestValuesForParametersTest()), - JsonBoolTests::NameGenerator{} + tests::util::NameGenerator ); TEST_P(JsonBoolTests, Parse) diff --git a/tests/unit/rpc/handlers/AMMInfoTests.cpp b/tests/unit/rpc/handlers/AMMInfoTests.cpp index 4bced0a27..91a3288bf 100644 --- a/tests/unit/rpc/handlers/AMMInfoTests.cpp +++ b/tests/unit/rpc/handlers/AMMInfoTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AMMInfo.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -66,15 +67,7 @@ struct AMMInfoParamTestCaseBundle { std::string expectedErrorMessage; }; -struct AMMInfoParameterTest : public RPCAMMInfoHandlerTest, public WithParamInterface { - struct NameGenerator { - std::string - operator()(auto const& info) const - { - return static_cast(info.param).testName; - } - }; -}; +struct AMMInfoParameterTest : public RPCAMMInfoHandlerTest, public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -106,7 +99,7 @@ INSTANTIATE_TEST_CASE_P( RPCAMMInfoGroup1, AMMInfoParameterTest, ValuesIn(generateTestValuesForParametersTest()), - AMMInfoParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AMMInfoParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/AccountInfoTests.cpp b/tests/unit/rpc/handlers/AccountInfoTests.cpp index 8effd0aed..478227094 100644 --- a/tests/unit/rpc/handlers/AccountInfoTests.cpp +++ b/tests/unit/rpc/handlers/AccountInfoTests.cpp @@ -24,6 +24,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AccountInfo.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -62,17 +63,7 @@ struct AccountInfoParamTestCaseBundle { // parameterized test cases for parameters check struct AccountInfoParameterTest : public RPCAccountInfoHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -114,7 +105,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountInfoGroup1, AccountInfoParameterTest, ValuesIn(generateTestValuesForParametersTest()), - AccountInfoParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountInfoParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/AccountNFTsTests.cpp b/tests/unit/rpc/handlers/AccountNFTsTests.cpp index 2de6e1e39..ceb95e7a8 100644 --- a/tests/unit/rpc/handlers/AccountNFTsTests.cpp +++ b/tests/unit/rpc/handlers/AccountNFTsTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AccountNFTs.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -66,17 +67,7 @@ struct AccountNFTParamTestCaseBundle { // parameterized test cases for parameters check struct AccountNFTParameterTest : public RPCAccountNFTsHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -155,7 +146,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountNFTsGroup1, AccountNFTParameterTest, ValuesIn(generateTestValuesForParametersTest()), - AccountNFTParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountNFTParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/AccountObjectsTests.cpp b/tests/unit/rpc/handlers/AccountObjectsTests.cpp index f18ec0537..63ea10760 100644 --- a/tests/unit/rpc/handlers/AccountObjectsTests.cpp +++ b/tests/unit/rpc/handlers/AccountObjectsTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AccountObjects.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -71,17 +72,7 @@ struct AccountObjectsParamTestCaseBundle { // parameterized test cases for parameters check struct AccountObjectsParameterTest : public RPCAccountObjectsHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -180,7 +171,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountObjectsGroup1, AccountObjectsParameterTest, ValuesIn(generateTestValuesForParametersTest()), - AccountObjectsParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountObjectsParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/AccountOffersTests.cpp b/tests/unit/rpc/handlers/AccountOffersTests.cpp index c7cb116a7..980be7904 100644 --- a/tests/unit/rpc/handlers/AccountOffersTests.cpp +++ b/tests/unit/rpc/handlers/AccountOffersTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AccountOffers.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -62,17 +63,7 @@ struct AccountOfferParamTestCaseBundle { // parameterized test cases for parameters check struct AccountOfferParameterTest : public RPCAccountOffersHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -151,7 +142,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountOffersGroup1, AccountOfferParameterTest, ValuesIn(generateTestValuesForParametersTest()), - AccountOfferParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountOfferParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/AccountTxTests.cpp b/tests/unit/rpc/handlers/AccountTxTests.cpp index a8bc677d3..1b25f1e9f 100644 --- a/tests/unit/rpc/handlers/AccountTxTests.cpp +++ b/tests/unit/rpc/handlers/AccountTxTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/AccountTx.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -63,15 +64,6 @@ struct AccountTxParamTestCaseBundle { // parameterized test cases for parameters check struct AccountTxParameterTest : public RPCAccountTxHandlerTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - return info.param.testName; - } - }; - static auto generateTestValuesForParametersTest() { @@ -401,7 +393,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountTxGroup1, AccountTxParameterTest, ValuesIn(AccountTxParameterTest::generateTestValuesForParametersTest()), - AccountTxParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountTxParameterTest, CheckParams) @@ -1564,17 +1556,7 @@ struct AccountTxTransactionBundle { // parameterized test cases for parameters check struct AccountTxTransactionTypeTest : public RPCAccountTxHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTransactionTypeTestValues() @@ -2049,7 +2031,7 @@ INSTANTIATE_TEST_CASE_P( RPCAccountTxTransactionTypeTest, AccountTxTransactionTypeTest, ValuesIn(generateTransactionTypeTestValues()), - AccountTxTransactionTypeTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(AccountTxTransactionTypeTest, SpecificTransactionType) diff --git a/tests/unit/rpc/handlers/BookChangesTests.cpp b/tests/unit/rpc/handlers/BookChangesTests.cpp index 4c7fd89a6..f4fdfb81d 100644 --- a/tests/unit/rpc/handlers/BookChangesTests.cpp +++ b/tests/unit/rpc/handlers/BookChangesTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/BookChanges.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -60,17 +61,7 @@ struct BookChangesParamTestCaseBundle { // parameterized test cases for parameters check struct BookChangesParameterTest : public RPCBookChangesHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -92,7 +83,7 @@ INSTANTIATE_TEST_CASE_P( RPCBookChangesGroup1, BookChangesParameterTest, ValuesIn(generateTestValuesForParametersTest()), - BookChangesParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(BookChangesParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/BookOffersTests.cpp b/tests/unit/rpc/handlers/BookOffersTests.cpp index 32464c1be..e2a53cdf3 100644 --- a/tests/unit/rpc/handlers/BookOffersTests.cpp +++ b/tests/unit/rpc/handlers/BookOffersTests.cpp @@ -24,6 +24,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/BookOffers.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -75,17 +76,7 @@ struct ParameterTestBundle { std::string expectedErrorMessage; }; -struct RPCBookOffersParameterTest : public RPCBookOffersHandlerTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct RPCBookOffersParameterTest : public RPCBookOffersHandlerTest, public WithParamInterface {}; TEST_P(RPCBookOffersParameterTest, CheckError) { @@ -497,7 +488,7 @@ INSTANTIATE_TEST_SUITE_P( RPCBookOffersHandler, RPCBookOffersParameterTest, testing::ValuesIn(generateParameterBookOffersTestBundles()), - RPCBookOffersParameterTest::NameGenerator() + tests::util::NameGenerator ); struct BookOffersNormalTestBundle { @@ -511,17 +502,7 @@ struct BookOffersNormalTestBundle { }; struct RPCBookOffersNormalPathTest : public RPCBookOffersHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; TEST_P(RPCBookOffersNormalPathTest, CheckOutput) { @@ -1172,7 +1153,7 @@ INSTANTIATE_TEST_SUITE_P( RPCBookOffersHandler, RPCBookOffersNormalPathTest, testing::ValuesIn(generateNormalPathBookOffersTestBundles()), - RPCBookOffersNormalPathTest::NameGenerator() + tests::util::NameGenerator ); // ledger not exist diff --git a/tests/unit/rpc/handlers/DepositAuthorizedTests.cpp b/tests/unit/rpc/handlers/DepositAuthorizedTests.cpp index e23bc4964..bf37d3de9 100644 --- a/tests/unit/rpc/handlers/DepositAuthorizedTests.cpp +++ b/tests/unit/rpc/handlers/DepositAuthorizedTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/DepositAuthorized.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -61,17 +62,7 @@ struct DepositAuthorizedTestCaseBundle { // parameterized test cases for parameters check struct DepositAuthorizedParameterTest : public RPCDepositAuthorizedTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -172,7 +163,7 @@ INSTANTIATE_TEST_CASE_P( RPCDepositAuthorizedGroup, DepositAuthorizedParameterTest, ValuesIn(generateTestValuesForParametersTest()), - DepositAuthorizedParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(DepositAuthorizedParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/GatewayBalancesTests.cpp b/tests/unit/rpc/handlers/GatewayBalancesTests.cpp index f1f16d6cc..268f79a41 100644 --- a/tests/unit/rpc/handlers/GatewayBalancesTests.cpp +++ b/tests/unit/rpc/handlers/GatewayBalancesTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/GatewayBalances.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -66,17 +67,7 @@ struct ParameterTestBundle { std::string expectedErrorMessage; }; -struct ParameterTest : public RPCGatewayBalancesHandlerTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct ParameterTest : public RPCGatewayBalancesHandlerTest, public WithParamInterface {}; TEST_P(ParameterTest, CheckError) { @@ -209,7 +200,7 @@ INSTANTIATE_TEST_SUITE_P( RPCGatewayBalancesHandler, ParameterTest, testing::ValuesIn(generateParameterTestBundles()), - ParameterTest::NameGenerator() + tests::util::NameGenerator ); TEST_F(RPCGatewayBalancesHandlerTest, LedgerNotFoundViaStringIndex) @@ -387,17 +378,7 @@ struct NormalTestBundle { std::string hotwallet; }; -struct NormalPathTest : public RPCGatewayBalancesHandlerTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct NormalPathTest : public RPCGatewayBalancesHandlerTest, public WithParamInterface {}; TEST_P(NormalPathTest, CheckOutput) { @@ -661,5 +642,5 @@ INSTANTIATE_TEST_SUITE_P( RPCGatewayBalancesHandler, NormalPathTest, testing::ValuesIn(generateNormalPathTestBundles()), - NormalPathTest::NameGenerator() + tests::util::NameGenerator ); diff --git a/tests/unit/rpc/handlers/GetAggregatePriceTests.cpp b/tests/unit/rpc/handlers/GetAggregatePriceTests.cpp index 20482c4a9..96368b2ab 100644 --- a/tests/unit/rpc/handlers/GetAggregatePriceTests.cpp +++ b/tests/unit/rpc/handlers/GetAggregatePriceTests.cpp @@ -23,6 +23,7 @@ #include "rpc/handlers/GetAggregatePrice.hpp" #include "util/Fixtures.hpp" #include "util/MockBackend.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -104,17 +105,7 @@ struct GetAggregatePriceParamTestCaseBundle { // parameterized test cases for parameters check struct GetAggregatePriceParameterTest : public RPCGetAggregatePriceHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -315,7 +306,7 @@ INSTANTIATE_TEST_CASE_P( RPCGetAggregatePriceGroup1, GetAggregatePriceParameterTest, ValuesIn(generateTestValuesForParametersTest()), - GetAggregatePriceParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(GetAggregatePriceParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/LedgerDataTests.cpp b/tests/unit/rpc/handlers/LedgerDataTests.cpp index 98b4fc8ee..6aba48ddc 100644 --- a/tests/unit/rpc/handlers/LedgerDataTests.cpp +++ b/tests/unit/rpc/handlers/LedgerDataTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/LedgerData.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -62,17 +63,7 @@ struct LedgerDataParamTestCaseBundle { // parameterized test cases for parameters check struct LedgerDataParameterTest : public RPCLedgerDataHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -113,7 +104,7 @@ INSTANTIATE_TEST_CASE_P( RPCLedgerDataGroup1, LedgerDataParameterTest, ValuesIn(generateTestValuesForParametersTest()), - LedgerDataParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(LedgerDataParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/LedgerEntryTests.cpp b/tests/unit/rpc/handlers/LedgerEntryTests.cpp index 448d992cc..81ecea6bb 100644 --- a/tests/unit/rpc/handlers/LedgerEntryTests.cpp +++ b/tests/unit/rpc/handlers/LedgerEntryTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/LedgerEntry.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -71,17 +72,7 @@ struct ParamTestCaseBundle { }; // parameterized test cases for parameters check -struct LedgerEntryParameterTest : public RPCLedgerEntryTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct LedgerEntryParameterTest : public RPCLedgerEntryTest, public WithParamInterface {}; // TODO: because we extract the error generation from the handler to framework // the error messages need one round fine tuning @@ -1770,7 +1761,7 @@ INSTANTIATE_TEST_CASE_P( RPCLedgerEntryGroup1, LedgerEntryParameterTest, ValuesIn(generateTestValuesForParametersTest()), - LedgerEntryParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(LedgerEntryParameterTest, InvalidParams) @@ -1881,17 +1872,7 @@ struct NormalPathTestBundle { ripple::STObject mockedEntity; }; -struct RPCLedgerEntryNormalPathTest : public RPCLedgerEntryTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct RPCLedgerEntryNormalPathTest : public RPCLedgerEntryTest, public WithParamInterface {}; static auto generateTestValuesForNormalPathTest() @@ -2391,7 +2372,7 @@ INSTANTIATE_TEST_CASE_P( RPCLedgerEntryGroup2, RPCLedgerEntryNormalPathTest, ValuesIn(generateTestValuesForNormalPathTest()), - RPCLedgerEntryNormalPathTest::NameGenerator{} + tests::util::NameGenerator ); // Test for normal path diff --git a/tests/unit/rpc/handlers/LedgerTests.cpp b/tests/unit/rpc/handlers/LedgerTests.cpp index 67e65c2da..33cd18bd4 100644 --- a/tests/unit/rpc/handlers/LedgerTests.cpp +++ b/tests/unit/rpc/handlers/LedgerTests.cpp @@ -25,6 +25,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/Ledger.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -68,17 +69,7 @@ struct LedgerParamTestCaseBundle { }; // parameterized test cases for parameters check -struct LedgerParameterTest : public RPCLedgerHandlerTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct LedgerParameterTest : public RPCLedgerHandlerTest, public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -175,7 +166,7 @@ INSTANTIATE_TEST_CASE_P( RPCLedgerGroup1, LedgerParameterTest, ValuesIn(generateTestValuesForParametersTest()), - LedgerParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(LedgerParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/NFTHistoryTests.cpp b/tests/unit/rpc/handlers/NFTHistoryTests.cpp index 057bf0266..36d00549b 100644 --- a/tests/unit/rpc/handlers/NFTHistoryTests.cpp +++ b/tests/unit/rpc/handlers/NFTHistoryTests.cpp @@ -23,6 +23,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/NFTHistory.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -59,17 +60,7 @@ struct NFTHistoryParamTestCaseBundle { // parameterized test cases for parameters check struct NFTHistoryParameterTest : public RPCNFTHistoryHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -232,7 +223,7 @@ INSTANTIATE_TEST_CASE_P( RPCNFTHistoryGroup1, NFTHistoryParameterTest, ValuesIn(generateTestValuesForParametersTest()), - NFTHistoryParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(NFTHistoryParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/NoRippleCheckTests.cpp b/tests/unit/rpc/handlers/NoRippleCheckTests.cpp index 7af51b7c6..4036b7fa9 100644 --- a/tests/unit/rpc/handlers/NoRippleCheckTests.cpp +++ b/tests/unit/rpc/handlers/NoRippleCheckTests.cpp @@ -22,6 +22,7 @@ #include "rpc/common/Types.hpp" #include "rpc/handlers/NoRippleCheck.hpp" #include "util/Fixtures.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include @@ -60,17 +61,7 @@ struct NoRippleParamTestCaseBundle { // parameterized test cases for parameters check struct NoRippleCheckParameterTest : public RPCNoRippleCheckTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -166,7 +157,7 @@ INSTANTIATE_TEST_CASE_P( RPCNoRippleCheckGroup1, NoRippleCheckParameterTest, ValuesIn(generateTestValuesForParametersTest()), - NoRippleCheckParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(NoRippleCheckParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/SubscribeTests.cpp b/tests/unit/rpc/handlers/SubscribeTests.cpp index 5520b638d..16e0e8006 100644 --- a/tests/unit/rpc/handlers/SubscribeTests.cpp +++ b/tests/unit/rpc/handlers/SubscribeTests.cpp @@ -26,6 +26,7 @@ #include "rpc/handlers/Subscribe.hpp" #include "util/Fixtures.hpp" #include "util/MockWsBase.hpp" +#include "util/NameGenerator.hpp" #include "util/TestObject.hpp" #include "web/interface/ConnectionBase.hpp" @@ -91,17 +92,7 @@ struct SubscribeParamTestCaseBundle { // parameterized test cases for parameters check struct SubscribeParameterTest : public RPCSubscribeHandlerTest, - public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -577,7 +568,7 @@ INSTANTIATE_TEST_CASE_P( RPCSubscribe, SubscribeParameterTest, ValuesIn(generateTestValuesForParametersTest()), - SubscribeParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(SubscribeParameterTest, InvalidParams) diff --git a/tests/unit/rpc/handlers/UnsubscribeTests.cpp b/tests/unit/rpc/handlers/UnsubscribeTests.cpp index 2a512fcee..79a4f299b 100644 --- a/tests/unit/rpc/handlers/UnsubscribeTests.cpp +++ b/tests/unit/rpc/handlers/UnsubscribeTests.cpp @@ -25,6 +25,7 @@ #include "util/Fixtures.hpp" #include "util/MockSubscriptionManager.hpp" #include "util/MockWsBase.hpp" +#include "util/NameGenerator.hpp" #include "web/interface/ConnectionBase.hpp" #include @@ -73,17 +74,8 @@ struct UnsubscribeParamTestCaseBundle { }; // parameterized test cases for parameters check -struct UnsubscribeParameterTest : public RPCUnsubscribeTest, public WithParamInterface { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct UnsubscribeParameterTest : public RPCUnsubscribeTest, + public WithParamInterface {}; static auto generateTestValuesForParametersTest() @@ -519,7 +511,7 @@ INSTANTIATE_TEST_CASE_P( RPCUnsubscribe, UnsubscribeParameterTest, ValuesIn(generateTestValuesForParametersTest()), - UnsubscribeParameterTest::NameGenerator{} + tests::util::NameGenerator ); TEST_P(UnsubscribeParameterTest, InvalidParams) diff --git a/tests/unit/util/prometheus/HttpTests.cpp b/tests/unit/util/prometheus/HttpTests.cpp index 4392aebe3..382ad92e5 100644 --- a/tests/unit/util/prometheus/HttpTests.cpp +++ b/tests/unit/util/prometheus/HttpTests.cpp @@ -17,6 +17,7 @@ */ //============================================================================== #include "util/MockPrometheus.hpp" +#include "util/NameGenerator.hpp" #include "util/config/Config.hpp" #include "util/prometheus/Http.hpp" #include "util/prometheus/Label.hpp" @@ -46,17 +47,7 @@ struct PrometheusCheckRequestTestsParams { bool expected; }; -struct PrometheusCheckRequestTests : public ::testing::TestWithParam { - struct NameGenerator { - template - std::string - operator()(testing::TestParamInfo const& info) const - { - auto bundle = static_cast(info.param); - return bundle.testName; - } - }; -}; +struct PrometheusCheckRequestTests : public ::testing::TestWithParam {}; TEST_P(PrometheusCheckRequestTests, isPrometheusRequest) { @@ -113,7 +104,7 @@ INSTANTIATE_TEST_CASE_P( .expected = false }, }), - PrometheusCheckRequestTests::NameGenerator() + tests::util::NameGenerator ); struct PrometheusHandleRequestTests : util::prometheus::WithPrometheus {