MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / TEST

Function TEST

test/component/ComponentValidatorTest.cpp:21–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19}();
20
21TEST(ComponentValidatorTest, MissingArgument) {
22 AST::Component::Component Comp;
23 // Add both sections first, then access by index to avoid invalidation.
24 Comp.getSections().emplace_back();
25 Comp.getSections().back().emplace<AST::Component::ComponentSection>();
26 Comp.getSections().emplace_back();
27 Comp.getSections().back().emplace<AST::Component::InstanceSection>();
28 auto &CompSec =
29 std::get<AST::Component::ComponentSection>(Comp.getSections()[0]);
30 auto &InstSec =
31 std::get<AST::Component::InstanceSection>(Comp.getSections()[1]);
32
33 CompSec.getContent() = std::make_unique<AST::Component::Component>();
34 CompSec.getContent()->getSections().emplace_back();
35 CompSec.getContent()
36 ->getSections()
37 .back()
38 .emplace<AST::Component::ImportSection>();
39 auto &ImpSec = std::get<AST::Component::ImportSection>(
40 CompSec.getContent()->getSections().back());
41 ImpSec.getContent().emplace_back();
42 ImpSec.getContent().back().getName() = "f";
43 ImpSec.getContent().back().getDesc().setFuncTypeIdx(0);
44
45 InstSec.getContent().emplace_back();
46 AST::Component::InstantiateArg<AST::Component::SortIndex> Arg;
47 Arg.getName() = "g";
48 Arg.getIndex().getSort().setSortType(AST::Component::Sort::SortType::Func);
49 Arg.getIndex().setIdx(0);
50 InstSec.getContent().back().setInstantiateArgs(0U, {Arg});
51
52 Validator::Validator V(Conf);
53 ASSERT_FALSE(V.validate(Comp));
54}
55
56TEST(ComponentValidatorTest, TypeMismatch) {
57 AST::Component::Component Comp;

Callers

nothing calls this directly

Calls 15

FuncTypeClass · 0.85
ResourceTypeClass · 0.85
to_stringFunction · 0.85
ComponentValTypeClass · 0.85
FunctionTypeClass · 0.85
mkOptFunction · 0.85
makeCompWithImportedFuncFunction · 0.85
getSectionsMethod · 0.80
backMethod · 0.80
setFuncTypeIdxMethod · 0.80

Tested by

no test coverage detected