forked from standardese/cppast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparser.cpp
More file actions
63 lines (46 loc) · 1.6 KB
/
Copy pathparser.cpp
File metadata and controls
63 lines (46 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors
// SPDX-License-Identifier: MIT
#include <cppast/parser.hpp>
#include <catch2/catch.hpp>
using namespace cppast;
TEST_CASE("parse_files")
{
class null_compile_config : public compile_config
{
public:
null_compile_config() : compile_config({}) {}
private:
void do_set_flags(cpp_standard, compile_flags) override {}
void do_add_include_dir(std::string) override {}
void do_add_macro_definition(std::string, std::string) override {}
void do_remove_macro_definition(std::string) override {}
const char* do_get_name() const noexcept override
{
return "null";
}
bool do_use_c() const noexcept override
{
return false;
}
} config;
class null_parser : public parser
{
public:
using config = null_compile_config;
null_parser() : parser(type_safe::ref(logger_)) {}
private:
std::unique_ptr<cpp_file> do_parse(const cpp_entity_index& idx, std::string path,
const compile_config&) const override
{
return cpp_file::builder(std::move(path)).finish(idx);
}
stderr_diagnostic_logger logger_;
};
cpp_entity_index idx;
simple_file_parser<null_parser> parser(type_safe::ref(idx));
auto file_names = {"a.cpp", "b.cpp", "c.cpp"};
parse_files(parser, file_names, config);
auto iter = file_names.begin();
for (auto& file : parser.files())
REQUIRE(file.name() == *iter++);
}