forked from bytecodealliance/wit-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.cpp
More file actions
120 lines (94 loc) · 4.1 KB
/
Copy pathtest.cpp
File metadata and controls
120 lines (94 loc) · 4.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#include <assert.h>
#include <test_cpp.h>
#include <float.h>
#include <math.h>
#include <vector>
uint32_t exports::test::lists::to_test::AllocatedBytes() {
return 0;
}
template <class T, class S>
static bool equal(T const&a, S const& b) {
return a == b;
}
template<class R, class S>
static bool equal(std::span<R> const&a, std::span<S> const& b) {
if (a.size() != b.size()) { return false; }
for (uint32_t i = 0; i<a.size(); ++i) {
if (!equal(a[i], b[i])) { return false; }
}
return true;
}
template<class R>
static bool equal(wit::vector<R> const&a, std::vector<R> const& b) {
return equal(a.get_view(), std::span<R const>(b));
}
static bool equal(wit::string const& a, std::string_view b) {
return a.get_view() == b;
}
void exports::test::lists::to_test::EmptyListParam(wit::vector<uint8_t> a) {
assert(a.empty());
}
void exports::test::lists::to_test::EmptyStringParam(wit::string a) {
assert(a.empty());
}
wit::vector<uint8_t> exports::test::lists::to_test::EmptyListResult() {
return wit::vector<uint8_t>();
}
wit::string exports::test::lists::to_test::EmptyStringResult() {
return wit::string::from_view(std::string_view());
}
void exports::test::lists::to_test::ListParam(wit::vector<uint8_t> list) {
assert(equal(list, std::vector<uint8_t>{1, 2, 3, 4}));
}
void exports::test::lists::to_test::ListParam2(wit::string ptr) {
assert(equal(ptr, std::string_view("foo")));
}
void exports::test::lists::to_test::ListParam3(wit::vector<wit::string> ptr) {
assert(equal(ptr.size(), size_t(3)));
assert(equal(ptr[0], std::string_view("foo")));
assert(equal(ptr[1], std::string_view("bar")));
assert(equal(ptr[2], std::string_view("baz")));
}
void exports::test::lists::to_test::ListParam4(wit::vector<wit::vector<wit::string>> ptr) {
assert(equal(ptr.size(), size_t(2)));
assert(equal(ptr[0][0], std::string_view("foo")));
assert(equal(ptr[0][1], std::string_view("bar")));
assert(equal(ptr[1][0], std::string_view("baz")));
}
void exports::test::lists::to_test::ListParam5(wit::vector<std::tuple<uint8_t, uint32_t, uint8_t>> a) {
}
void exports::test::lists::to_test::ListParamLarge(wit::vector<wit::string> a) {
}
wit::vector<uint8_t> exports::test::lists::to_test::ListResult() {
return wit::vector<uint8_t>::from_view(std::span<uint8_t const>(std::vector<uint8_t>{1, 2, 3, 4, 5}));
}
wit::string exports::test::lists::to_test::ListResult2() {
return wit::string::from_view("hello!");
}
wit::vector<wit::string> exports::test::lists::to_test::ListResult3() {
return wit::vector<wit::string>::from_view(std::span<wit::string const>(std::vector<wit::string>{wit::string::from_view("hello,"), wit::string::from_view("world!")}));
}
wit::vector<uint8_t> exports::test::lists::to_test::ListRoundtrip(wit::vector<uint8_t> x) {
return x;
}
wit::string exports::test::lists::to_test::StringRoundtrip(wit::string x) {
return x;
}
std::tuple<wit::vector<uint8_t>, wit::vector<int8_t>> exports::test::lists::to_test::ListMinmax8(wit::vector<uint8_t> a, wit::vector<int8_t> b) {
return std::make_tuple(std::move(a), std::move(b));
}
std::tuple<wit::vector<uint16_t>, wit::vector<int16_t>> exports::test::lists::to_test::ListMinmax16(wit::vector<uint16_t> a, wit::vector<int16_t> b) {
return std::make_tuple(std::move(a), std::move(b));
}
std::tuple<wit::vector<uint32_t>, wit::vector<int32_t>> exports::test::lists::to_test::ListMinmax32(wit::vector<uint32_t> a, wit::vector<int32_t> b) {
return std::make_tuple(std::move(a), std::move(b));
}
std::tuple<wit::vector<uint64_t>, wit::vector<int64_t>> exports::test::lists::to_test::ListMinmax64(wit::vector<uint64_t> a, wit::vector<int64_t> b) {
return std::make_tuple(std::move(a), std::move(b));
}
std::tuple<wit::vector<float>, wit::vector<double>> exports::test::lists::to_test::ListMinmaxFloat(wit::vector<float> a, wit::vector<double> b) {
return std::make_tuple(std::move(a), std::move(b));
}
wit::vector<std::tuple<wit::string, wit::vector<uint8_t>>> exports::test::lists::to_test::WasiHttpHeadersRoundtrip(wit::vector<std::tuple<wit::string, wit::vector<uint8_t>>> a) {
return a;
}