From 3de1a44912918e1948b6434039a84a126e0417b1 Mon Sep 17 00:00:00 2001 From: NicoMoser <14797302+NicoMoser@users.noreply.github.com> Date: Sun, 26 Nov 2023 18:49:55 -0500 Subject: [PATCH] Support older GCC versions Pre-version 11 results in errors like error: call of overloaded 'Sqids()' is ambiguous --- tests/blocklistTests.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/tests/blocklistTests.cpp b/tests/blocklistTests.cpp index efd5222..72998d0 100644 --- a/tests/blocklistTests.cpp +++ b/tests/blocklistTests.cpp @@ -9,17 +9,30 @@ TEST(Blocklist, IfNoCustomBlocklistParamUseTheDefaultBlocklist) { } TEST(Blocklist, IfAnEmptyBlocklistParamPassedDontUseAnyBlocklist) { +#if __GNUC__ <= 10 + sqidscxx::SqidsOptions sqidsOptions; + sqidsOptions.blocklist.clear(); + sqidscxx::Sqids<> sqids(sqidsOptions); +#else sqidscxx::Sqids<> sqids({ blocklist: {} }); - +#endif + EXPECT_EQ(sqids.decode("aho1e"), sqids.numbers({ 4572721 })); EXPECT_EQ(sqids.encode({ 4572721 }), "aho1e"); } TEST(Blocklist, IfANonEmptyBlocklistParamPassedUseOnlyThat) { +#if __GNUC__ <= 10 + sqidscxx::SqidsOptions sqidsOptions; + sqidsOptions.blocklist.clear(); + sqidsOptions.blocklist.insert("ArUO"); + sqidscxx::Sqids<> sqids(sqidsOptions); +#else sqidscxx::Sqids<> sqids({ blocklist: { "ArUO" // originally encoded [100000] } }); - +#endif + // Make sure we don't use the default blocklist EXPECT_EQ(sqids.decode("aho1e"), sqids.numbers({ 4572721 })); EXPECT_EQ(sqids.encode({ 4572721 }), "aho1e"); @@ -54,7 +67,13 @@ TEST(Blocklist, DecodingBlocklistWordsShouldStillWork) { } TEST(Blocklist, MatchAgainstAShortBlocklistWord) { +#if __GNUC__ <= 10 + sqidscxx::SqidsOptions sqidsOptions; + sqidsOptions.blocklist.insert("pnd"); + sqidscxx::Sqids<> sqids(sqidsOptions); +#else sqidscxx::Sqids<> sqids({ blocklist: { "pnd" } }); +#endif EXPECT_EQ(sqids.decode(sqids.encode({ 1000 })), sqids.numbers({ 1000 })); }