| 19 | }(); |
| 20 | |
| 21 | TEST(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 | |
| 56 | TEST(ComponentValidatorTest, TypeMismatch) { |
| 57 | AST::Component::Component Comp; |
nothing calls this directly
no test coverage detected