1#include <xrpl/beast/core/LexicalCast.h>
2#include <xrpl/beast/unit_test/suite.h>
3#include <xrpl/beast/xor_shift_engine.h>
15 template <
class IntType>
19 return static_cast<IntType
>(r());
22 template <
class IntType>
27 IntType out =
static_cast<IntType
>(~in);
34 template <
class IntType>
40 ss <<
"random " <<
typeid(IntType).name();
43 for (
int i = 0; i < 1000; ++i)
52 ss <<
"numeric_limits <" <<
typeid(IntType).name() <<
">";
164 bool result = !success;
177 expect(result == success, s);
238 expect(result == actual, actual +
" (string to integer)");
240 if (result == actual)
245 expect(
false, actual +
" (integer to string)");
static IntType nextRandomInt(xor_shift_engine &r)
void testIntegers(xor_shift_engine &r)
void testThrowingConversions()
void run() override
Runs the suite.
void testConversionUnderflows()
void testConversionOverflows()
bool tryEdgeCase(std::string const &s)
void testInteger(IntType in)
void testThrowConvert(std::string const &s, bool success)
void tryBadConvert(std::string const &s)
void pass()
Record a successful test condition.
bool expect(Condition const &shouldBeTrue)
Evaluate a test condition.
TestcaseT testcase
Memberspace for declaring test cases.
Out lexicalCastThrow(In in)
Convert from one type to another, throw on error.
detail::XorShiftEngine<> xor_shift_engine
XOR-shift Generator.
Out lexicalCast(In in, Out defaultValue=Out())
Convert from one type to another.
BEAST_DEFINE_TESTSUITE(aged_set, beast, beast)
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Thrown when a conversion is not possible with LexicalCast.