Wire Sysio
Wire Sysion 1.0.0
Loading...
Searching...
No Matches
max_nested_structures_tests.cpp
Go to the documentation of this file.
1
#include <sysio/vm/backend.hpp>
2
3
#include "
utils.hpp
"
4
#include <
catch2/catch.hpp
>
5
6
using namespace
sysio::vm
;
7
8
extern
wasm_allocator
wa
;
9
10
namespace
{
11
12
/*
13
* (module
14
* (func (block)
15
* )
16
*/
17
std::vector<uint8_t> depth_2_wasm = {
18
0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60,
19
0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x0a, 0x07, 0x01, 0x05, 0x00, 0x02,
20
0x40, 0x0b, 0x0b
21
};
22
23
struct
empty_options {};
24
struct
static_options_1 {
25
static
constexpr
std::uint32_t max_nested_structures = 1;
26
};
27
struct
static_options_2 {
28
static
constexpr
std::uint32_t max_nested_structures = 2;
29
};
30
struct
dynamic_options {
31
std::uint32_t max_nested_structures;
32
};
33
34
}
35
36
BACKEND_TEST_CASE
(
"Test max_nested_structures default"
,
"[max_nested_structures_test]"
) {
37
using
backend_t
=
backend<std::nullptr_t, TestType>
;
38
backend_t
backend
(depth_2_wasm, &
wa
);
39
}
40
41
BACKEND_TEST_CASE
(
"Test max_nested_structures unlimited"
,
"[max_nested_structures_test]"
) {
42
using
backend_t
=
backend<std::nullptr_t, TestType, empty_options>
;
43
backend_t
backend
(depth_2_wasm, &
wa
);
44
}
45
46
BACKEND_TEST_CASE
(
"Test max_nested_structures static fail"
,
"[max_nested_structures_test]"
) {
47
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_1>
;
48
CHECK_THROWS_AS
(
backend_t
(depth_2_wasm, &
wa
), wasm_parse_exception);
49
}
50
51
BACKEND_TEST_CASE
(
"Test max_nested_structures static pass"
,
"[max_nested_structures_test]"
) {
52
using
backend_t
=
backend<std::nullptr_t, TestType, static_options_2>
;
53
backend_t
backend
(depth_2_wasm, &
wa
);
54
}
55
56
BACKEND_TEST_CASE
(
"Test max_nested_structures dynamic fail"
,
"[max_nested_structures_test]"
) {
57
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
58
CHECK_THROWS_AS
(
backend_t
(depth_2_wasm,
nullptr
, dynamic_options{1}), wasm_parse_exception);
59
}
60
61
BACKEND_TEST_CASE
(
"Test max_nested_structures dynamic pass"
,
"[max_nested_structures_test]"
) {
62
using
backend_t
=
backend<std::nullptr_t, TestType, dynamic_options>
;
63
backend_t
backend
(depth_2_wasm,
nullptr
, dynamic_options{2});
64
}
sysio::vm::backend
Definition
backend.hpp:62
sysio::vm::wasm_allocator
Definition
allocator.hpp:409
backend_t
sysio::vm::backend< rhf_t > backend_t
Definition
hello_driver.cpp:61
CHECK_THROWS_AS
#define CHECK_THROWS_AS(expr, exceptionType)
Definition
catch.hpp:203
wa
wasm_allocator wa
Definition
main.cpp:10
sysio::vm
Definition
controller.hpp:23
catch.hpp
utils.hpp
BACKEND_TEST_CASE
#define BACKEND_TEST_CASE(name, tags)
Definition
utils.hpp:59
libraries
sys-vm
tests
max_nested_structures_tests.cpp
Generated by
1.12.0