More tests on data formatter
This commit is contained in:
parent
cf22f8c569
commit
186fea1383
@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
using namespace Leonetienne::GCrypt;
|
using namespace Leonetienne::GCrypt;
|
||||||
|
|
||||||
// Tests that recoding iobase format works
|
// Tests that recoding iobase formats works for individual blocks, with random data
|
||||||
TEMPLATE_TEST_CASE_SIG(
|
TEMPLATE_TEST_CASE_SIG(
|
||||||
__FILE__"Data formats can be converted, without changing in value",
|
__FILE__"Data formats can be converted, without changing in value, with indivudual blocks, with random data",
|
||||||
"[ModuleDataFormatter]",
|
"[ModuleDataFormatter]",
|
||||||
((Configuration::IOBASE_FORMAT formatUnderTest), formatUnderTest),
|
((Configuration::IOBASE_FORMAT formatUnderTest), formatUnderTest),
|
||||||
Configuration::IOBASE_FORMAT::BASE_BYTES,
|
Configuration::IOBASE_FORMAT::BASE_BYTES,
|
||||||
@ -26,12 +26,11 @@ TEMPLATE_TEST_CASE_SIG(
|
|||||||
|
|
||||||
GPrng prng(Key::Random());
|
GPrng prng(Key::Random());
|
||||||
|
|
||||||
// Let's try 50 different random blocks per test
|
// Let's try 10 different random blocks per test
|
||||||
for (std::size_t i = 0; i < 50; i++) {
|
for (std::size_t i = 0; i < 10; i++) {
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
Block b_initial;
|
const Block b_initial = prng.GetBlock();
|
||||||
b_initial = prng.GetBlock();
|
|
||||||
|
|
||||||
// Exercise
|
// Exercise
|
||||||
// Convert to a custom base
|
// Convert to a custom base
|
||||||
@ -52,3 +51,40 @@ TEMPLATE_TEST_CASE_SIG(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that recoding iobase format works
|
||||||
|
TEMPLATE_TEST_CASE_SIG(
|
||||||
|
__FILE__"Data formats can be converted, without changing in value, with indivudual blocks, with very little data (lots of nullbytes)",
|
||||||
|
"[ModuleDataFormatter]",
|
||||||
|
((Configuration::IOBASE_FORMAT formatUnderTest), formatUnderTest),
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_BYTES,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_2,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_8,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_10,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_16,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_64,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_UWU,
|
||||||
|
Configuration::IOBASE_FORMAT::BASE_UGH
|
||||||
|
) {
|
||||||
|
|
||||||
|
// Setup
|
||||||
|
Block b_initial;
|
||||||
|
b_initial.FromTextString("Heyu");
|
||||||
|
|
||||||
|
// Exercise
|
||||||
|
// Convert to a custom base
|
||||||
|
const std::string b_format = ModuleDataFormatter::FormatBlock(
|
||||||
|
b_initial,
|
||||||
|
formatUnderTest
|
||||||
|
);
|
||||||
|
|
||||||
|
// Convert back to a block
|
||||||
|
const Block b_retrieved = ModuleDataFormatter::DecodeFormat(
|
||||||
|
b_format,
|
||||||
|
formatUnderTest
|
||||||
|
);
|
||||||
|
|
||||||
|
// Verify
|
||||||
|
// Do b_initial and b_retrieved match?
|
||||||
|
REQUIRE(b_initial == b_retrieved);
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user