Skip to content

Commit

Permalink
Merge pull request #4 from NicoMoser/main
Browse files Browse the repository at this point in the history
Support older GCC versions
  • Loading branch information
laserpants authored Nov 27, 2023
2 parents 19de1a5 + 3de1a44 commit 291071f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions tests/blocklistTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 }));
}
Expand Down

0 comments on commit 291071f

Please sign in to comment.