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

Method TestImports

tests/runtime/resources/resources.cpp:16–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16std::expected<void, wit::string> exports::test::resources::TestImports() {
17 auto y = ::test::resources::Y(10);
18 assert(equal(y.GetA(), 10));
19 y.SetA(20);
20 assert(equal(y.GetA(), 20));
21 auto y2a = ::test::resources::Y::Add(std::move(y), 20);
22 assert(equal(y2a.GetA(), 40));
23
24 // test multiple instances
25 auto y1 = ::test::resources::Y(1);
26 auto y2 = ::test::resources::Y(2);
27 assert(equal(y1.GetA(), 1));
28 assert(equal(y2.GetA(), 2));
29 y1.SetA(10);
30 y2.SetA(20);
31 assert(equal(y1.GetA(), 10));
32 assert(equal(y2.GetA(), 20));
33 auto y3 = ::test::resources::Y::Add(std::move(y1), 20);
34 auto y4 = ::test::resources::Y::Add(std::move(y2), 30);
35 assert(equal(y3.GetA(), 30));
36 assert(equal(y4.GetA(), 50));
37 return std::expected<void, wit::string>();
38}
39
40uint32_t exports::test::resources::Z::num_dropped = 0;

Callers 1

RunFunction · 0.45

Calls 6

YStruct · 0.85
AddFunction · 0.85
equalFunction · 0.70
assertFunction · 0.50
GetAMethod · 0.45
SetAMethod · 0.45

Tested by

no test coverage detected