forked from Alepha/Alepha
Simple number-printing utility function.
4271 -> "Four thousand two hundred seventy one" Why? Well, for one it permits the generation of larger strings from simple 32-bit seed numbers. This permits sort of a "decompression" of string data from simple inputs to do some fuzz testing or other things.
This commit is contained in:
BIN
Utility/print_number.test/.0.cc.swp
Normal file
BIN
Utility/print_number.test/.0.cc.swp
Normal file
Binary file not shown.
39
Utility/print_number.test/0.cc
Normal file
39
Utility/print_number.test/0.cc
Normal file
@ -0,0 +1,39 @@
|
||||
static_assert( __cplusplus > 2020'99 );
|
||||
|
||||
#include "../print_number.h"
|
||||
|
||||
#include <Alepha/Testing/TableTest.h>
|
||||
#include <Alepha/Testing/test.h>
|
||||
|
||||
#include <Alepha/Utility/evaluation_helpers.h>
|
||||
|
||||
static auto init= Alepha::Utility::enroll <=[]
|
||||
{
|
||||
using namespace Alepha::Testing::exports;
|
||||
"Do simple numerical tests come out as we want?"_test
|
||||
<=TableTest< Alepha::Utility::formatPrint >::Cases
|
||||
{
|
||||
{ "zero", { 0 }, "zero" },
|
||||
{ "one", { 1 }, "one" },
|
||||
{ "seven hundred", { 700 }, "seven hundred" },
|
||||
{ "one thousand twenty four", { 1024 }, "one thousand twenty four" },
|
||||
{ "ten thousand two hundred forty", { 10240 }, "ten thousand two hundred forty" },
|
||||
{ "1283721", { 1'283'721 }, "one million two hundred eighty three thousand seven hundred twenty one" },
|
||||
{ "1000283000721", { 1'000'283'000'721 },
|
||||
"one trillion two hundred eighty three million seven hundred twenty one" },
|
||||
|
||||
{ "1000283000721", { 1'000'283'000'000 },
|
||||
"one trillion two hundred eighty three million" },
|
||||
};
|
||||
|
||||
-"repl"_test <=[]
|
||||
{
|
||||
while( std::cin )
|
||||
{
|
||||
std::uint64_t value;
|
||||
std::cout << "input: " << std::flush;
|
||||
std::cin >> value;
|
||||
std::cout << Alepha::Utility::formatPrint( value ) << std::endl;
|
||||
}
|
||||
};
|
||||
};
|
||||
1
Utility/print_number.test/CMakeLists.txt
Normal file
1
Utility/print_number.test/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
||||
unit_test( 0 )
|
||||
Reference in New Issue
Block a user