Add exclude_return and exclude_target code generation options

This commit is contained in:
Jonathan Müller 2017-05-25 21:04:50 +02:00
commit c86e950847
5 changed files with 151 additions and 29 deletions

View file

@ -6,11 +6,15 @@
#include "test_parser.hpp"
using namespace cppast;
TEST_CASE("code_generator")
{
// no need to check much here, as each entity check separately
// only write some file with equivalent code and synopsis
auto code = R"(using type=int;
SECTION("basic")
{
// no need to check much here, as each entity check separately
// only write some file with equivalent code and synopsis
auto code = R"(using type=int;
struct foo{
int a;
@ -34,6 +38,60 @@ void func(int(*)(int));
extern void(* ptr)(int(*)(int))=&func;
)";
auto file = parse({}, "code_generator.cpp", code);
REQUIRE(get_code(*file) == code);
auto file = parse({}, "code_generator.cpp", code);
REQUIRE(get_code(*file) == code);
}
SECTION("exclude target")
{
auto code = R"(
namespace a {}
namespace b = a;
using c = int*;
typedef int d;
)";
auto synopsis = R"(namespace a{
}
namespace b=excluded;
using c=excluded;
using d=excluded;
)";
auto file = parse({}, "code_generator_exclude_target.cpp", code);
REQUIRE(get_code(*file, code_generator::exclude_target) == synopsis);
}
SECTION("exclude return")
{
auto code = R"(
void a();
template <typename T>
auto b() -> int*;
struct foo
{
int c() const&;
operator const int ();
};
)";
auto synopsis = R"(excluded a();
template<typename T>
excluded b();
struct foo{
excluded c()const&;
operator excluded();
};
)";
auto file = parse({}, "code_generator_exclude_return.cpp", code);
REQUIRE(get_code(*file, code_generator::exclude_return) == synopsis);
}
}