Sen API
Sen Libraries
Loading...
Searching...
No Matches
plantuml_fixture_test.h
Go to the documentation of this file.
1// === plantuml_fixture_test.h =========================================================================================
2// Sen Infrastructure
3// Released under the Apache License v2.0 (SPDX-License-Identifier Apache-2.0).
4// See the LICENSE.txt file for more information.
5// © Airbus SAS, Airbus Helicopters, and Airbus Defence and Space SAU/GmbH/SAS.
6// =====================================================================================================================
7
8#ifndef SEN_LIBS_GEN_TEST_PLANTUML_FIXTURE_TEST_H
9#define SEN_LIBS_GEN_TEST_PLANTUML_FIXTURE_TEST_H
10
11#include "sen/gen/plantuml.h"
12
13// sen
19
20// 3rd party
21#include <gtest/gtest.h>
22
23// std
24#include <cstddef>
25#include <filesystem>
26#include <string>
27#include <vector>
28
29class APlantUMLGenerator: public ::testing::Test
30{
31protected:
32 bool generateStl(const std::string& stl,
35 {
36 sen::lang::StlScanner scanner {stl};
37 sen::lang::StlParser parser {scanner.scanTokens()};
38 statements_ = parser.parse();
39
40 sen::lang::ResolverContext resolverContext {};
41 sen::lang::StlResolver resolver {statements_, resolverContext, context_};
42
43 if (resolver.resolve({}) == nullptr)
44 {
45 return false;
46 }
47
48 content_ = sen::gen::PlantUMLGenerator {}.generate(context_, generationMode, enumMode);
49 return true;
50 }
51
52 void generateFom(const std::vector<std::filesystem::path>& paths,
55 {
57 content_ = sen::gen::PlantUMLGenerator {}.generate(context_, generationMode, enumMode);
58 }
59
60 [[nodiscard]] std::size_t find(const std::string& phrase, std::size_t from = 0) const
61 {
62 return content_.find(phrase, from);
63 }
64
65 [[nodiscard]] std::string content() const { return content_; }
66
67 [[nodiscard]] std::filesystem::path dataDirectoryPath() const { return TEST_DATA_DIR; }
68
69private:
70 std::vector<sen::lang::StlStatement> statements_;
72 std::string content_;
73};
74
75#endif // SEN_LIBS_GEN_TEST_PLANTUML_FIXTURE_TEST_H
Definition plantuml_fixture_test.h:30
std::filesystem::path dataDirectoryPath() const
Definition plantuml_fixture_test.h:67
std::size_t find(const std::string &phrase, std::size_t from=0) const
Definition plantuml_fixture_test.h:60
bool generateStl(const std::string &stl, sen::gen::PlantUMLGenerationMode generationMode=sen::gen::PlantUMLGenerationMode::all, sen::gen::PlantUMLEnumMode enumMode=sen::gen::PlantUMLEnumMode::all)
Definition plantuml_fixture_test.h:32
void generateFom(const std::vector< std::filesystem::path > &paths, sen::gen::PlantUMLGenerationMode generationMode=sen::gen::PlantUMLGenerationMode::all, sen::gen::PlantUMLEnumMode enumMode=sen::gen::PlantUMLEnumMode::all)
Definition plantuml_fixture_test.h:52
std::string content() const
Definition plantuml_fixture_test.h:65
Renders PlantUML class diagrams out of sen type sets. Stateful (caches the loaded inja templates),...
Definition plantuml.h:38
std::string generate(const sen::lang::TypeSetContext &typeSets, PlantUMLGenerationMode generationMode, PlantUMLEnumMode enumMode)
Renders one PlantUML document covering every type set in the supplied context. The two mode parameter...
Parses STL types and queries out of a list of tokens.
Definition stl_parser.h:30
std::vector< StlStatement > parse()
Parse the tokens given in the constructor into a set of statements.
Resolves a list of statements into a set of types.
Definition stl_resolver.h:102
const TypeSet * resolve(const TypeSettings &settings)
Do the resolution based on the inputs passed on the constructor.
Converts a string into a list of tokens.
Definition stl_scanner.h:31
const StlTokenList & scanTokens()
Scans the string. Throws in case of error.
The set of types used during resolution.
Definition stl_resolver.h:51
PlantUMLEnumMode
Controls whether enum types contribute their enumerators to the rendered diagram.
Definition plantuml.h:30
PlantUMLGenerationMode
Selects which subset of the type set ends up in the rendered diagram.
Definition plantuml.h:22
@ all
Definition plantuml.h:31
@ all
Definition plantuml.h:23
TypeSetContext parseFomDocuments(const std::vector< std::filesystem::path > &paths, const std::vector< std::filesystem::path > &mappings, const TypeSettings &settings)
Definition fom_parser.h:52
The environment where a resolution takes place.
Definition stl_resolver.h:43
Definition stl_resolver.h:95