From 000f45e1f4aa7de60d84b1f2bcc002ee183002ee Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Fri, 10 Mar 2023 13:17:05 +0100 Subject: [PATCH] tests/base58/encode.cpp: add subcase and fix test structs. --- tests/base58/encode.cpp | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/tests/base58/encode.cpp b/tests/base58/encode.cpp index 7728be9..6d47ed4 100644 --- a/tests/base58/encode.cpp +++ b/tests/base58/encode.cpp @@ -3,24 +3,32 @@ #include #include -typedef std::pair testpair_t; -typedef std::vector tests; - TEST_CASE("base58::base58_encode") { - tests input = { - testpair_t("",""), - testpair_t( - "Quisque ut ipsum lorem. Nullam ac justo elit. Sed gravida convallis mattis.", - "2nPTv2DT874jRaYBN4uhM9mT2iRiwdJuCXuX5buUHyyvWUSu6cX62i8HYo8PsWqgs9DHbwhpSpV5SVUnCqyLcpxcuGanH68eXgzZTGq" - ), - testpair_t( - "Cras fringilla, eros et imperdiet tincidunt", - "5yAgp6rBagDHQZ3GacZSeaEPF2jfuwVHM21aNfXETJgn3EkArxc5UWSq1RM" - ), + struct testcase { + const char* name; + std::string in; + std::string expected; }; - for(tests::const_iterator it = input.begin(); it != input.end(); it++) { - CHECK( libeosio::base58_encode(it->first) == it->second ); + std::vector tests = { + {"empty","",""}, + { + "first", + "Quisque ut ipsum lorem. Nullam ac justo elit. Sed gravida convallis mattis.", + "2nPTv2DT874jRaYBN4uhM9mT2iRiwdJuCXuX5buUHyyvWUSu6cX62i8HYo8PsWqgs9DHbwhpSpV5SVUnCqyLcpxcuGanH68eXgzZTGq" + }, + { + "second", + "Cras fringilla, eros et imperdiet tincidunt", + "5yAgp6rBagDHQZ3GacZSeaEPF2jfuwVHM21aNfXETJgn3EkArxc5UWSq1RM" + }, + }; + + for(auto it = tests.begin(); it != tests.end(); it++) { + + SUBCASE(it->name) { + CHECK( libeosio::base58_encode(it->in) == it->expected ); + } } } \ No newline at end of file