Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
start_tests.cpp File Reference
#include <algorithm>
#include <vector>
#include <iostream>
#include <iterator>
#include <cmath>
#include <cstdlib>
#include <catch2/catch.hpp>
#include <utils.hpp>
#include <wasm_config.hpp>
#include <sysio/vm/backend.hpp>
Include dependency graph for start_tests.cpp:

Go to the source code of this file.

Functions

 BACKEND_TEST_CASE ("Testing wasm <start_0_wasm>", "[start_0_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <start_1_wasm>", "[start_1_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <start_2_wasm>", "[start_2_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <start_3_wasm>", "[start_3_wasm_tests]")
 
 BACKEND_TEST_CASE ("Testing wasm <start_4_wasm>", "[start_4_wasm_tests]")
 

Variables

wasm_allocator wa
 

Function Documentation

◆ BACKEND_TEST_CASE() [1/5]

BACKEND_TEST_CASE ( "Testing wasm <start_0_wasm>" ,
"" [start_0_wasm_tests] )

Definition at line 18 of file start_tests.cpp.

18 {
20 auto code = read_wasm( std::string(wasm_directory) + "start.0.wasm");
21 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
22}
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
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [2/5]

BACKEND_TEST_CASE ( "Testing wasm <start_1_wasm>" ,
"" [start_1_wasm_tests] )

Definition at line 24 of file start_tests.cpp.

24 {
26 auto code = read_wasm( std::string(wasm_directory) + "start.1.wasm");
27 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
28}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [3/5]

BACKEND_TEST_CASE ( "Testing wasm <start_2_wasm>" ,
"" [start_2_wasm_tests] )

Definition at line 30 of file start_tests.cpp.

30 {
32 auto code = read_wasm( std::string(wasm_directory) + "start.2.wasm");
33 CHECK_THROWS_AS(backend_t(code, nullptr), std::exception);
34}
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [4/5]

BACKEND_TEST_CASE ( "Testing wasm <start_3_wasm>" ,
"" [start_3_wasm_tests] )

Definition at line 36 of file start_tests.cpp.

36 {
38 auto code = read_wasm( std::string(wasm_directory) + "start.3.wasm");
39 backend_t bkend( code, &wa );
40
41 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(68));
42bkend("env", "inc");
43 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(69));
44bkend("env", "inc");
45 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(70));
46}
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
#define UINT32_C(val)
Definition stdint.h:283
Here is the call graph for this function:

◆ BACKEND_TEST_CASE() [5/5]

BACKEND_TEST_CASE ( "Testing wasm <start_4_wasm>" ,
"" [start_4_wasm_tests] )

Definition at line 48 of file start_tests.cpp.

48 {
50 auto code = read_wasm( std::string(wasm_directory) + "start.4.wasm");
51 backend_t bkend( code, &wa );
52
53 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(68));
54bkend("env", "inc");
55 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(69));
56bkend("env", "inc");
57 CHECK(bkend.call_with_return("env", "get")->to_ui32() == UINT32_C(70));
58}
Here is the call graph for this function:

Variable Documentation

◆ wa

wasm_allocator wa
extern

Definition at line 10 of file main.cpp.