-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convert_to_base_64 function to convert string integer to magnitudes
- Loading branch information
Showing
4 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "function/utility.hpp" | ||
|
||
#include "third_party/catch.hpp" | ||
|
||
TEST_CASE("Conversion to Base64 magnitudes from String", "[Utility][Helper][Base64]") { | ||
std::string num = "481482486096808911670147153572883801"; | ||
// Magnitude should be {11670147153572883801, 4814824860968089} | ||
auto magnitude = convert_to_base_64(num); | ||
REQUIRE(magnitude.size() == 2); | ||
REQUIRE(magnitude[0] == uint64_t(11670147153572883801)); | ||
REQUIRE(magnitude[1] == uint64_t(4814824860968089)); | ||
|
||
num = "1"; | ||
magnitude = convert_to_base_64(num); | ||
REQUIRE(magnitude.size() == 1); | ||
REQUIRE(magnitude[0] == uint64_t(1)); | ||
|
||
num = ""; | ||
magnitude = convert_to_base_64(num); | ||
REQUIRE(magnitude.size() == 1); | ||
REQUIRE(magnitude[0] == uint64_t(0)); | ||
} |