1
0
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:
2024-03-04 15:33:59 -05:00
parent 08654a9a86
commit e25b171e6b
5 changed files with 156 additions and 0 deletions

Binary file not shown.

View 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;
}
};
};

View File

@ -0,0 +1 @@
unit_test( 0 )