Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
switch_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 <switch_0_wasm>", "[switch_0_wasm_tests]" ) {
20 auto code = read_wasm( std::string(wasm_directory) + "switch.0.wasm");
21 backend_t bkend( code, &wa );
22
23 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(0))->to_ui32() == UINT32_C(0));
24 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(1))->to_ui32() == UINT32_C(4294967295));
25 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(2))->to_ui32() == UINT32_C(4294967294));
26 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(3))->to_ui32() == UINT32_C(4294967293));
27 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(4))->to_ui32() == UINT32_C(100));
28 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(5))->to_ui32() == UINT32_C(101));
29 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(6))->to_ui32() == UINT32_C(102));
30 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(7))->to_ui32() == UINT32_C(100));
31 CHECK(bkend.call_with_return("env", "stmt", UINT32_C(4294967286))->to_ui32() == UINT32_C(102));
32 CHECK(bkend.call_with_return("env", "expr", UINT64_C(0))->to_ui64() == UINT32_C(0));
33 CHECK(bkend.call_with_return("env", "expr", UINT64_C(1))->to_ui64() == UINT32_C(18446744073709551615));
34 CHECK(bkend.call_with_return("env", "expr", UINT64_C(2))->to_ui64() == UINT32_C(18446744073709551614));
35 CHECK(bkend.call_with_return("env", "expr", UINT64_C(3))->to_ui64() == UINT32_C(18446744073709551613));
36 CHECK(bkend.call_with_return("env", "expr", UINT64_C(6))->to_ui64() == UINT32_C(101));
37 CHECK(bkend.call_with_return("env", "expr", UINT64_C(7))->to_ui64() == UINT32_C(18446744073709551611));
38 CHECK(bkend.call_with_return("env", "expr", UINT64_C(18446744073709551606))->to_ui64() == UINT32_C(100));
39 CHECK(bkend.call_with_return("env", "arg", UINT32_C(0))->to_ui32() == UINT32_C(110));
40 CHECK(bkend.call_with_return("env", "arg", UINT32_C(1))->to_ui32() == UINT32_C(12));
41 CHECK(bkend.call_with_return("env", "arg", UINT32_C(2))->to_ui32() == UINT32_C(4));
42 CHECK(bkend.call_with_return("env", "arg", UINT32_C(3))->to_ui32() == UINT32_C(1116));
43 CHECK(bkend.call_with_return("env", "arg", UINT32_C(4))->to_ui32() == UINT32_C(118));
44 CHECK(bkend.call_with_return("env", "arg", UINT32_C(5))->to_ui32() == UINT32_C(20));
45 CHECK(bkend.call_with_return("env", "arg", UINT32_C(6))->to_ui32() == UINT32_C(12));
46 CHECK(bkend.call_with_return("env", "arg", UINT32_C(7))->to_ui32() == UINT32_C(1124));
47 CHECK(bkend.call_with_return("env", "arg", UINT32_C(8))->to_ui32() == UINT32_C(126));
48 CHECK(bkend.call_with_return("env", "corner")->to_ui32() == UINT32_C(1));
49}
50
51BACKEND_TEST_CASE( "Testing wasm <switch_1_wasm>", "[switch_1_wasm_tests]" ) {
53 auto code = read_wasm( std::string(wasm_directory) + "switch.1.wasm");
54 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
55}
56
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)
sysio::vm::backend< rhf_t > backend_t
#define CHECK_THROWS_AS(expr, exceptionType)
Definition catch.hpp:203
std::vector< uint8_t > read_wasm(const std::string &fname)
Definition utils.hpp:30
#define UINT32_C(val)
Definition stdint.h:283
#define UINT64_C(val)
Definition stdint.h:284
wasm_allocator wa
Definition main.cpp:10
#define BACKEND_TEST_CASE(name, tags)
Definition utils.hpp:59