// Copyright (C) 2017-2022 Jonathan Müller and cppast contributors // SPDX-License-Identifier: MIT #include #include "test_parser.hpp" using namespace cppast; TEST_CASE("code_generator") { // no need to check much here, as each entity check separately auto code = R"(using type=int; type* var; templateclass... T> struct templated{ }; using struct_=int; struct_ var2; struct foo{ using my_int=int; my_int a; auto func(int)->int(*(*)(int))[42]; private: int const b=42; }; int(*(*(foo::* mptr)(int))(int))[42]; enum class bar :int{ a, b=42 }; void func(int(*)(int)); extern void(* ptr)(int(*)(int))=&func;)"; auto file = parse({}, "code_generator.cpp", code); SECTION("basic") { REQUIRE(get_code(*file) == code); } SECTION("formatting") { auto synopsis = R"(using type = int; type* var; template