/** * tests/test_cases.cc * * Copyright (c) 2021 Bartek Kryza * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #define CATCH_CONFIG_MAIN #include "test_cases.h" std::pair load_config( const std::string &test_name) { auto config = clanguml::config::load(test_name + "/.clanguml"); auto db = clanguml::cx::compilation_database::from_directory( config.compilation_database_dir); return std::make_pair(std::move(config), std::move(db)); } clanguml::model::sequence_diagram::diagram generate_sequence_diagram( compilation_database &db, std::shared_ptr diagram) { auto diagram_model = clanguml::generators::sequence_diagram::generate(db, diagram->name, dynamic_cast(*diagram)); return diagram_model; } clanguml::model::class_diagram::diagram generate_class_diagram( compilation_database &db, std::shared_ptr diagram) { auto diagram_model = clanguml::generators::class_diagram::generate(db, diagram->name, dynamic_cast(*diagram)); return diagram_model; } std::string generate_sequence_puml( std::shared_ptr config, clanguml::model::sequence_diagram::diagram &model) { using namespace clanguml::generators::sequence_diagram::puml; std::stringstream ss; ss << generator( dynamic_cast(*config), model); return ss.str(); } std::string generate_class_puml( std::shared_ptr config, clanguml::model::class_diagram::diagram &model) { using namespace clanguml::generators::class_diagram::puml; std::stringstream ss; ss << generator( dynamic_cast(*config), model); return ss.str(); } void save_puml(const std::string &path, const std::string &puml) { std::filesystem::path p{path}; std::filesystem::create_directory(p.parent_path()); spdlog::error("PWD: {}", std::filesystem::current_path().string()); spdlog::error("SAVING TEST PWD {} DIAGRAM: {}", p.string()); std::ofstream ofs; ofs.open(p, std::ofstream::out | std::ofstream::trunc); ofs << puml; ofs.close(); } #include "t00001/test_case.h" #include "t00002/test_case.h" #include "t00003/test_case.h" #include "t00004/test_case.h"