Added test for unnamed enums
This commit is contained in:
@@ -296,30 +296,38 @@ void tu_visitor::process_class_declaration(const cppast::cpp_class &cls)
|
|||||||
if (cppast::is_templated(cls)) {
|
if (cppast::is_templated(cls)) {
|
||||||
LOG_DBG("Processing class template parameters...");
|
LOG_DBG("Processing class template parameters...");
|
||||||
auto scope = cppast::cpp_scope_name(type_safe::ref(cls));
|
auto scope = cppast::cpp_scope_name(type_safe::ref(cls));
|
||||||
for (const auto &tp : scope.template_parameters()) {
|
// Even if this is a template the scope.is_templated() returns
|
||||||
if (tp.kind() ==
|
// false when the template parameter list is empty
|
||||||
cppast::cpp_entity_kind::template_type_parameter_t) {
|
if (scope.is_templated()) {
|
||||||
LOG_DBG("Processing template type parameter {}", tp.name());
|
for (const auto &tp : scope.template_parameters()) {
|
||||||
process_template_type_parameter(
|
if (tp.kind() ==
|
||||||
static_cast<const cppast::cpp_template_type_parameter &>(
|
cppast::cpp_entity_kind::template_type_parameter_t) {
|
||||||
tp),
|
LOG_DBG("Processing template type parameter {}", tp.name());
|
||||||
c);
|
process_template_type_parameter(
|
||||||
}
|
static_cast<
|
||||||
else if (tp.kind() ==
|
const cppast::cpp_template_type_parameter &>(tp),
|
||||||
cppast::cpp_entity_kind::non_type_template_parameter_t) {
|
c);
|
||||||
LOG_DBG("Processing template nontype parameter {}", tp.name());
|
}
|
||||||
process_template_nontype_parameter(
|
else if (tp.kind() ==
|
||||||
static_cast<
|
cppast::cpp_entity_kind::non_type_template_parameter_t) {
|
||||||
const cppast::cpp_non_type_template_parameter &>(tp),
|
LOG_DBG(
|
||||||
c);
|
"Processing template nontype parameter {}", tp.name());
|
||||||
}
|
process_template_nontype_parameter(
|
||||||
else if (tp.kind() ==
|
static_cast<
|
||||||
cppast::cpp_entity_kind::template_template_parameter_t) {
|
const cppast::cpp_non_type_template_parameter &>(
|
||||||
LOG_DBG("Processing template template parameter {}", tp.name());
|
tp),
|
||||||
process_template_template_parameter(
|
c);
|
||||||
static_cast<
|
}
|
||||||
const cppast::cpp_template_template_parameter &>(tp),
|
else if (tp.kind() ==
|
||||||
c);
|
cppast::cpp_entity_kind::template_template_parameter_t) {
|
||||||
|
LOG_DBG(
|
||||||
|
"Processing template template parameter {}", tp.name());
|
||||||
|
process_template_template_parameter(
|
||||||
|
static_cast<
|
||||||
|
const cppast::cpp_template_template_parameter &>(
|
||||||
|
tp),
|
||||||
|
c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -756,7 +764,7 @@ void tu_visitor::process_friend(const cppast::cpp_friend &f, class_ &parent)
|
|||||||
r.destination = name;
|
r.destination = name;
|
||||||
}
|
}
|
||||||
else if (f.entity()) {
|
else if (f.entity()) {
|
||||||
std::string name{};
|
std::string name {};
|
||||||
|
|
||||||
if (f.entity().value().kind() ==
|
if (f.entity().value().kind() ==
|
||||||
cppast::cpp_entity_kind::class_template_t) {
|
cppast::cpp_entity_kind::class_template_t) {
|
||||||
|
|||||||
12
tests/t00016/.clanguml
Normal file
12
tests/t00016/.clanguml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
compilation_database_dir: ..
|
||||||
|
output_directory: puml
|
||||||
|
diagrams:
|
||||||
|
t00016_class:
|
||||||
|
type: class
|
||||||
|
glob:
|
||||||
|
- ../../tests/t00016/t00016.cc
|
||||||
|
using_namespace:
|
||||||
|
- clanguml::t00016
|
||||||
|
include:
|
||||||
|
namespaces:
|
||||||
|
- clanguml::t00016
|
||||||
30
tests/t00016/t00016.cc
Normal file
30
tests/t00016/t00016.cc
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
namespace clanguml {
|
||||||
|
namespace t00016 {
|
||||||
|
|
||||||
|
template <typename>
|
||||||
|
struct is_numeric {
|
||||||
|
enum { value = false };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct is_numeric<char> {
|
||||||
|
enum { value = true };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct is_numeric<unsigned char> {
|
||||||
|
enum { value = true };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct is_numeric<int> {
|
||||||
|
enum { value = true };
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct is_numeric<bool> {
|
||||||
|
enum { value = false };
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
48
tests/t00016/test_case.h
Normal file
48
tests/t00016/test_case.h
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
/**
|
||||||
|
* tests/t00016/test_case.cc
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Bartek Kryza <bkryza@gmail.com>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
TEST_CASE("t00016", "[test-case][class]")
|
||||||
|
{
|
||||||
|
auto [config, db] = load_config("t00016");
|
||||||
|
|
||||||
|
auto diagram = config.diagrams["t00016_class"];
|
||||||
|
|
||||||
|
REQUIRE(diagram->name == "t00016_class");
|
||||||
|
|
||||||
|
REQUIRE(diagram->include.namespaces.size() == 1);
|
||||||
|
REQUIRE_THAT(diagram->include.namespaces,
|
||||||
|
VectorContains(std::string{"clanguml::t00016"}));
|
||||||
|
|
||||||
|
REQUIRE(diagram->exclude.namespaces.size() == 0);
|
||||||
|
|
||||||
|
REQUIRE(diagram->should_include("clanguml::t00016::is_numeric"));
|
||||||
|
|
||||||
|
auto model = generate_class_diagram(db, diagram);
|
||||||
|
|
||||||
|
REQUIRE(model.name == "t00016_class");
|
||||||
|
|
||||||
|
auto puml = generate_class_puml(diagram, model);
|
||||||
|
AliasMatcher _A(puml);
|
||||||
|
|
||||||
|
REQUIRE_THAT(puml, StartsWith("@startuml"));
|
||||||
|
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
|
||||||
|
REQUIRE_THAT(puml, IsClass(_A("is_numeric")));
|
||||||
|
|
||||||
|
save_puml(
|
||||||
|
"./" + config.output_directory + "/" + diagram->name + ".puml", puml);
|
||||||
|
}
|
||||||
@@ -119,6 +119,7 @@ using namespace clanguml::test::matchers;
|
|||||||
#include "t00013/test_case.h"
|
#include "t00013/test_case.h"
|
||||||
#include "t00014/test_case.h"
|
#include "t00014/test_case.h"
|
||||||
#include "t00015/test_case.h"
|
#include "t00015/test_case.h"
|
||||||
|
#include "t00016/test_case.h"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Sequence diagram tests
|
// Sequence diagram tests
|
||||||
|
|||||||
@@ -42,6 +42,9 @@ test_cases:
|
|||||||
- name: t00015
|
- name: t00015
|
||||||
title: Namespace fun
|
title: Namespace fun
|
||||||
description:
|
description:
|
||||||
|
- name: t00016
|
||||||
|
title: Unnamed enums and empty templates
|
||||||
|
description:
|
||||||
Sequence diagrams:
|
Sequence diagrams:
|
||||||
- name: t20001
|
- name: t20001
|
||||||
title: Basic sequence diagram
|
title: Basic sequence diagram
|
||||||
|
|||||||
Reference in New Issue
Block a user