23namespace sequoia::testing
26 bool handle_as_ref(std::string_view type);
30 std::string species, symbol;
36 using template_data = std::vector<template_spec>;
39 std::string to_string(
const template_data& data);
42 template_data generate_template_data(std::string_view str);
47 void cmake_nascent_tests(
const project_paths& projPaths, std::ostream& stream);
49 enum class nascent_test_flavour { standard, framework_diagnostics };
54 enum class gen_source_option {no, yes};
57 : m_Paths{std::move(paths)}
58 , m_Copyright{std::move(copyright)}
59 , m_CodeIndent{codeIndent}
61 , m_ProjectNamespace{back(m_Paths.source().project()).string()}
65 nascent_test_flavour flavour()
const noexcept {
return m_Flavour; }
67 void flavour(nascent_test_flavour f) { m_Flavour = f; }
70 const std::string&
suite()
const noexcept {
return m_Suite; }
72 void suite(std::string name) { m_Suite = std::move(name); }
75 const std::filesystem::path& header()
const noexcept {
return m_Header; }
77 void header(std::filesystem::path h) { m_Header = std::move(h); }
80 const std::string& test_type()
const noexcept {
return m_TestType; }
82 void test_type(std::string type) { m_TestType = std::move(type); }
85 const std::string& forename()
const noexcept {
return m_Forename; }
87 void forename(std::string name) { m_Forename = std::move(name); }
90 const std::string& surname()
const noexcept {
return m_Surname; }
92 void surname(std::string name) { m_Surname = std::move(name); }
94 void generate_source_files(gen_source_option opt)
100 const std::filesystem::path& host_dir()
const noexcept {
return m_HostDir; }
103 const std::filesystem::path& header_path()
const noexcept {
return m_HeaderPath; }
109 static std::vector<std::string> framework_diagnostics_stubs();
125 std::filesystem::path build_source_path(
const std::filesystem::path& filename)
const;
127 template<invocable_r<std::filesystem::path, std::filesystem::path> WhenAbsent,std::invocable<std::
string&> FileTransformer>
128 void finalize(WhenAbsent fn,
129 const std::vector<std::string>& stubs,
130 const std::vector<std::string>& constructors,
131 std::string_view nameStub,
132 FileTransformer transformer);
135 const std::string& camel_name()
const noexcept {
return m_CamelName; }
137 void camel_name(std::string name);
139 void set_cpp(
const std::filesystem::path& headerPath, std::string_view nameSpace);
142 const indentation& code_indent()
const noexcept {
return m_CodeIndent; }
145 const std::string& copyright()
const noexcept {
return m_Copyright; }
148 const std::string& project_namespace()
const noexcept {
return m_ProjectNamespace; }
151 std::ostream& stream()
noexcept {
return *m_Stream; }
153 void finalize_suite(std::string_view fallbackIngredient);
155 void make_common_replacements(std::string& text)
const;
157 constexpr static std::array<std::string_view, 3> st_HeaderExtensions{
".hpp",
".h",
".hxx"};
160 std::string m_Copyright{};
162 std::ostream* m_Stream;
164 nascent_test_flavour m_Flavour{nascent_test_flavour::standard};
171 m_ProjectNamespace{};
172 std::filesystem::path m_Header{}, m_HostDir{}, m_HeaderPath{};
173 gen_source_option m_SourceOption{};
175 void on_source_path_error()
const;
177 void finalize_header(
const std::filesystem::path& sourcePath);
179 template<std::invocable<std::
string&> FileTransformer>
181 std::string create_file(std::string_view inputNameStub, std::string_view nameEnding, FileTransformer transformer)
const;
188 using nascent_test_base::nascent_test_base;
190 void qualified_name(std::string name) { m_QualifiedName = std::move(name); }
192 void add_equivalent_type(std::string name) { m_EquivalentTypes.emplace_back(std::move(name)); }
194 void source_dir(std::filesystem::path dir) { m_SourceDir = std::move(dir); }
199 std::vector<std::string> constructors()
const;
205 static std::vector<std::string> stubs();
207 std::string m_QualifiedName{};
209 template_data m_TemplateData{};
211 std::vector<std::string> m_EquivalentTypes{};
213 std::filesystem::path m_SourceDir{};
215 void transform_file(std::string& text)
const;
217 void set_header_text(std::string& text, std::string_view copyright, std::string_view nameSpace)
const;
220 std::filesystem::path when_header_absent(
const std::filesystem::path& filename,
const std::string& nameSpace);
226 using nascent_test_base::nascent_test_base;
229 static std::vector<std::string> stubs();
234 std::vector<std::string> constructors()
const;
236 void transform_file(std::string& text)
const;
242 using nascent_test_base::nascent_test_base;
247 std::vector<std::string> constructors()
const;
253 static std::vector<std::string> stubs();
255 void set_namespace(std::string n) { m_Namespace = std::move(n); }
257 void transform_file(std::string& text)
const;
259 std::string m_Namespace;
262 std::filesystem::path when_header_absent(
const std::filesystem::path& filename);
267 using nascent_test_vessel =
typename nascent_test_factory::vessel;
Factory implementation(s)
Extensions to the std::filesystem library.
A collection of functions for formatting test output.
File paths pertaining to a sequoia project.
Type-safe mechanism for indentations.
Definition: Indent.hpp:22
Generic factory with statically defined products.
Definition: Factory.hpp:68
Definition: TestCreator.hpp:224
Definition: TestCreator.hpp:240
Definition: TestCreator.hpp:186
Definition: TestCreator.hpp:52
Paths used by the project.
Definition: ProjectPaths.hpp:469
Definition: TestCreator.hpp:29