Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
int_literals_tests.cpp
Go to the documentation of this file.
1// Generated by spec_test_generator. DO NOT MODIFY THIS FILE.
2
3#include <algorithm>
4#include <vector>
5#include <iostream>
6#include <iterator>
7#include <cmath>
8#include <cstdlib>
9#include <catch2/catch.hpp>
10#include <utils.hpp>
11#include <wasm_config.hpp>
12#include <sysio/vm/backend.hpp>
13
14using namespace sysio;
15using namespace sysio::vm;
16extern wasm_allocator wa;
17
18BACKEND_TEST_CASE( "Testing wasm <int_literals_0_wasm>", "[int_literals_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "int_literals.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "i32.test")->to_ui32() == UINT32_C(195940365));
24 CHECK(bkend.call_with_return("env", "i32.umax")->to_ui32() == UINT32_C(4294967295));
25 CHECK(bkend.call_with_return("env", "i32.smax")->to_ui32() == UINT32_C(2147483647));
26 CHECK(bkend.call_with_return("env", "i32.neg_smax")->to_ui32() == UINT32_C(2147483649));
27 CHECK(bkend.call_with_return("env", "i32.smin")->to_ui32() == UINT32_C(2147483648));
28 CHECK(bkend.call_with_return("env", "i32.alt_smin")->to_ui32() == UINT32_C(2147483648));
29 CHECK(bkend.call_with_return("env", "i32.inc_smin")->to_ui32() == UINT32_C(2147483649));
30 CHECK(bkend.call_with_return("env", "i32.neg_zero")->to_ui32() == UINT32_C(0));
31 CHECK(bkend.call_with_return("env", "i32.not_octal")->to_ui32() == UINT32_C(10));
32 CHECK(bkend.call_with_return("env", "i32.unsigned_decimal")->to_ui32() == UINT32_C(4294967295));
33 CHECK(bkend.call_with_return("env", "i32.plus_sign")->to_ui32() == UINT32_C(42));
34 CHECK(bkend.call_with_return("env", "i64.test")->to_ui64() == UINT32_C(913028331277281902));
35 CHECK(bkend.call_with_return("env", "i64.umax")->to_ui64() == UINT32_C(18446744073709551615));
36 CHECK(bkend.call_with_return("env", "i64.smax")->to_ui64() == UINT32_C(9223372036854775807));
37 CHECK(bkend.call_with_return("env", "i64.neg_smax")->to_ui64() == UINT32_C(9223372036854775809));
38 CHECK(bkend.call_with_return("env", "i64.smin")->to_ui64() == UINT32_C(9223372036854775808));
39 CHECK(bkend.call_with_return("env", "i64.alt_smin")->to_ui64() == UINT32_C(9223372036854775808));
40 CHECK(bkend.call_with_return("env", "i64.inc_smin")->to_ui64() == UINT32_C(9223372036854775809));
41 CHECK(bkend.call_with_return("env", "i64.neg_zero")->to_ui64() == UINT32_C(0));
42 CHECK(bkend.call_with_return("env", "i64.not_octal")->to_ui64() == UINT32_C(10));
43 CHECK(bkend.call_with_return("env", "i64.unsigned_decimal")->to_ui64() == UINT32_C(18446744073709551615));
44 CHECK(bkend.call_with_return("env", "i64.plus_sign")->to_ui64() == UINT32_C(42));
45 CHECK(bkend.call_with_return("env", "i32-dec-sep1")->to_ui32() == UINT32_C(1000000));
46 CHECK(bkend.call_with_return("env", "i32-dec-sep2")->to_ui32() == UINT32_C(1000));
47 CHECK(bkend.call_with_return("env", "i32-hex-sep1")->to_ui32() == UINT32_C(168755353));
48 CHECK(bkend.call_with_return("env", "i32-hex-sep2")->to_ui32() == UINT32_C(109071));
49 CHECK(bkend.call_with_return("env", "i64-dec-sep1")->to_ui64() == UINT32_C(1000000));
50 CHECK(bkend.call_with_return("env", "i64-dec-sep2")->to_ui64() == UINT32_C(1000));
51 CHECK(bkend.call_with_return("env", "i64-hex-sep1")->to_ui64() == UINT32_C(3078696982321561));
52 CHECK(bkend.call_with_return("env", "i64-hex-sep2")->to_ui64() == UINT32_C(109071));
53}
54
auto call_with_return(host_t &host, const std::string_view &mod, const std::string_view &func, Args... args)
Definition backend.hpp:178
#define CHECK(cond)
Definition util.h:80
backend_t bkend(hello_wasm, ehm, &wa)
wasm_allocator wa
Definition main.cpp:10
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59