MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / Run

Method Run

tests/runtime/lists/runner.cpp:53–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51}
52
53void exports::runner::Run()
54{
55 using namespace ::test::lists::to_test;
56
57 EmptyListParam(std::span<const uint8_t>(std::vector<uint8_t>()));
58 EmptyStringParam("");
59 assert(EmptyListResult().empty());
60 assert(EmptyStringResult().empty());
61
62 ListParam(std::vector<uint8_t>{1, 2, 3, 4});
63 ListParam2("foo");
64 ListParam3(std::vector<std::string_view>{"foo", "bar", "baz"});
65 ListParam4(std::vector<std::span<const std::string_view>>{
66 std::vector<std::string_view>{"foo", "bar"},
67 std::vector<std::string_view>{"baz"},
68 });
69 assert(equal(ListResult(), std::vector<uint8_t>{1, 2, 3, 4, 5}));
70 assert(equal(ListResult2(), "hello!"));
71 assert(equal(ListResult3(), std::vector<std::string_view>{"hello,", "world!"}));
72
73 assert(equal(ListRoundtrip(std::span<const uint8_t>(std::vector<uint8_t>())), std::vector<uint8_t>()));
74 assert(equal(ListRoundtrip(std::span<const uint8_t>(std::vector<uint8_t>{'x'})), std::vector<uint8_t>{'x'}));
75 assert(equal(ListRoundtrip(std::span<const uint8_t>(std::vector<uint8_t>{'h', 'e', 'l', 'l', 'o'})), std::vector<uint8_t>{'h', 'e', 'l', 'l', 'o'}));
76
77 assert(equal(StringRoundtrip("x"), "x"));
78 assert(equal(StringRoundtrip(""), ""));
79 assert(equal(StringRoundtrip("hello"), "hello"));
80 assert(equal(StringRoundtrip("hello ⚑ world"), "hello ⚑ world"));
81
82 assert(equal(
83 ListMinmax8(std::vector<uint8_t>{0, UINT8_MAX}, std::vector<int8_t>{INT8_MIN, INT8_MAX}),
84 std::make_tuple(std::vector<uint8_t>{0, UINT8_MAX}, std::vector<int8_t>{INT8_MIN, INT8_MAX})
85 ));
86 assert(equal(
87 ListMinmax16(std::vector<uint16_t>{0, UINT16_MAX}, std::vector<int16_t>{INT16_MIN, INT16_MAX}),
88 std::make_tuple(std::vector<uint16_t>{0, UINT16_MAX}, std::vector<int16_t>{INT16_MIN, INT16_MAX})
89 ));
90 assert(equal(
91 ListMinmax32(std::vector<uint32_t>{0, UINT32_MAX}, std::vector<int32_t>{INT32_MIN, INT32_MAX}),
92 std::make_tuple(std::vector<uint32_t>{0, UINT32_MAX}, std::vector<int32_t>{INT32_MIN, INT32_MAX})
93 ));
94 assert(equal(
95 ListMinmax64(std::vector<uint64_t>{0, UINT64_MAX}, std::vector<int64_t>{INT64_MIN, INT64_MAX}),
96 std::make_tuple(std::vector<uint64_t>{0, UINT64_MAX}, std::vector<int64_t>{INT64_MIN, INT64_MAX})
97 ));
98 assert(equal(
99 ListMinmaxFloat(
100 std::vector<float>{FLT_MIN, FLT_MAX, -HUGE_VALF, HUGE_VALF},
101 std::vector<double>{DBL_MIN, DBL_MAX, -HUGE_VAL, HUGE_VAL}
102 ),
103 std::make_tuple(
104 std::vector<float>{FLT_MIN, FLT_MAX, -HUGE_VALF, HUGE_VALF},
105 std::vector<double>{DBL_MIN, DBL_MAX, -HUGE_VAL, HUGE_VAL}
106 )
107 ));
108
109 {
110 std::vector<uint8_t> val0 = {'t', 'e', 'x', 't', '/', 'p', 'l', 'a', 'i', 'n'};

Callers

nothing calls this directly

Calls 15

EmptyListParamFunction · 0.85
EmptyStringParamFunction · 0.85
EmptyListResultFunction · 0.85
EmptyStringResultFunction · 0.85
ListParamFunction · 0.85
ListParam2Function · 0.85
ListParam3Function · 0.85
ListParam4Function · 0.85
ListResultFunction · 0.85
ListResult2Function · 0.85
ListResult3Function · 0.85
ListRoundtripFunction · 0.85

Tested by

no test coverage detected