Skip to content

Commit

Permalink
test: Add convenient _u32 and _u64 literals
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed Nov 18, 2020
1 parent e39ffac commit 8b3aa64
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/unittests/execute_numeric_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ using namespace fizzy::test;

namespace
{
inline constexpr uint64_t operator"" _u64(unsigned long long x)
{
const auto v = static_cast<uint64_t>(x);
if (v != x)
throw "integer literal is too large to be represented in the u64 type";
return v;
}

inline constexpr uint32_t operator"" _u32(unsigned long long x)
{
const auto v = static_cast<uint32_t>(x);
if (v != x)
throw "integer literal is too large to be represented in the u32 type";
return v;
}

auto create_unary_operation_executor(Instr instr)
{
auto module{std::make_unique<Module>()};
Expand Down

0 comments on commit 8b3aa64

Please sign in to comment.