Specialized soruce files for utility domains
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
#include <GeneralUtility.h>
|
||||
#include <BaseConversion.h>
|
||||
#include "Catch2.h"
|
||||
|
||||
// Tests base 10 to 10
|
||||
TEST_CASE(__FILE__"/Base10_to_10", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/Base10_to_10", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
const std::string set = "0123456789";
|
||||
@@ -10,14 +10,14 @@ TEST_CASE(__FILE__"/Base10_to_10", "[Base10_2_X]")
|
||||
const std::string expected_out = "1990381";
|
||||
|
||||
// Exercise
|
||||
const std::string out = GeneralUtility::Base10_2_X(in, set);
|
||||
const std::string out = BaseConversion::Base10_2_X(in, set);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
}
|
||||
|
||||
// Tests base 10 to 16
|
||||
TEST_CASE(__FILE__"/Base10_to_16", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/Base10_to_16", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
const std::string set = "0123456789abcdef";
|
||||
@@ -25,14 +25,14 @@ TEST_CASE(__FILE__"/Base10_to_16", "[Base10_2_X]")
|
||||
const std::string expected_out = "1990381";
|
||||
|
||||
// Exercise
|
||||
const std::string out = GeneralUtility::Base10_2_X(in, set);
|
||||
const std::string out = BaseConversion::Base10_2_X(in, set);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
}
|
||||
|
||||
// Tests base 10 to 2
|
||||
TEST_CASE(__FILE__"/Base10_to_2", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/Base10_to_2", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
const std::string set = "01";
|
||||
@@ -40,14 +40,14 @@ TEST_CASE(__FILE__"/Base10_to_2", "[Base10_2_X]")
|
||||
const std::string expected_out = "10111011";
|
||||
|
||||
// Exercise
|
||||
const std::string out = GeneralUtility::Base10_2_X(in, set);
|
||||
const std::string out = BaseConversion::Base10_2_X(in, set);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
}
|
||||
|
||||
// Tests base 10 to fucking big
|
||||
TEST_CASE(__FILE__"/Base10_to_FuckingBig", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/Base10_to_FuckingBig", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
const std::string set = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
@@ -55,14 +55,14 @@ TEST_CASE(__FILE__"/Base10_to_FuckingBig", "[Base10_2_X]")
|
||||
const std::string expected_out = "rn5qZuTD";
|
||||
|
||||
// Exercise
|
||||
const std::string out = GeneralUtility::Base10_2_X(in, set);
|
||||
const std::string out = BaseConversion::Base10_2_X(in, set);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
}
|
||||
|
||||
// Tests that padding works
|
||||
TEST_CASE(__FILE__"/TestPadding", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/TestPadding", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
const std::string set = "01";
|
||||
@@ -70,14 +70,14 @@ TEST_CASE(__FILE__"/TestPadding", "[Base10_2_X]")
|
||||
const std::string expected_out = "00000101";
|
||||
|
||||
// Exercise
|
||||
const std::string out = GeneralUtility::Base10_2_X(in, set, 8);
|
||||
const std::string out = BaseConversion::Base10_2_X(in, set, 8);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
}
|
||||
|
||||
// Tests that conversion with more complex 'digits' works. Weird-ass usecase
|
||||
TEST_CASE(__FILE__"/BaseWeird_to_10", "[Base10_2_X]")
|
||||
TEST_CASE(__FILE__"/BaseWeird_to_10", "[BaseConversion][Base10_2_X]")
|
||||
{
|
||||
// Setup
|
||||
|
||||
@@ -90,7 +90,7 @@ TEST_CASE(__FILE__"/BaseWeird_to_10", "[Base10_2_X]")
|
||||
const std::vector<std::string> expected_out = { "Apple", "Cherry", "Strawberry" };
|
||||
|
||||
// Exercise
|
||||
const std::vector<std::string> out = GeneralUtility::Base10_2_X(in, set);
|
||||
const std::vector<std::string> out = BaseConversion::Base10_2_X(in, set);
|
||||
|
||||
// Verify
|
||||
REQUIRE(out == expected_out);
|
||||
|
||||
Reference in New Issue
Block a user