Fixed class template handling

This commit is contained in:
Bartek Kryza
2022-05-07 19:59:13 +02:00
parent f264d71d3b
commit f5d80e90a3
11 changed files with 185 additions and 91 deletions

View File

@@ -27,22 +27,25 @@ template <typename T, typename P> struct A {
P p;
};
template <typename T> using AString = A<T, std::string>;
template <typename T> using AStringPtr = A<T, std::unique_ptr<std::string>>;
template <class T> using VectorPtr = std::unique_ptr<std::vector<T>>;
template <class T> using APtr = std::unique_ptr<A<double, T>>;
template <class T> using ASharedPtr = std::shared_ptr<A<double,T>>;
template <class T, class U> using AAPtr =
std::unique_ptr<std::pair<A<double,T>, A<long,U>>>;
template <typename... T> using GeneralCallback = std::function<void(T..., int)>;
using VoidCallback = GeneralCallback<>;
struct B {
std::string value;
};
template <typename T> using AString = A<T, std::string>;
template <typename T> using AStringPtr = A<T, std::unique_ptr<std::string>>;
template <typename T>
using PairPairBA = std::pair<std::pair<B, A<long, T>>, long>;
template <class T> using VectorPtr = std::unique_ptr<std::vector<T>>;
template <class T> using APtr = std::unique_ptr<A<double, T>>;
template <class T> using ASharedPtr = std::shared_ptr<A<double, T>>;
template <class T, class U>
using AAPtr = std::unique_ptr<std::pair<A<double, T>, A<long, U>>>;
template <typename... T> using GeneralCallback = std::function<void(T..., int)>;
using VoidCallback = GeneralCallback<>;
using BVector = std::vector<B>;
using BVector2 = BVector;
@@ -50,13 +53,11 @@ using AIntString = AString<int>;
using AStringString = AString<std::string>;
using BStringString = AStringString;
template <typename T> using PairPairBA = std::pair<std::pair<B, A<long,T>>, long>;
class R {
PairPairBA<bool> bapair;
APtr<bool> abool;
AAPtr<bool,float> aboolfloat;
AAPtr<bool, float> aboolfloat;
ASharedPtr<float> afloat;
A<bool, std::string> boolstring;
AStringPtr<float> floatstring;

View File

@@ -38,7 +38,7 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsClassTemplate("A", "T,std::string"));
REQUIRE_THAT(puml, IsClassTemplate("A", "T,std::unique_ptr<std::string>"));
REQUIRE_THAT(puml, IsClassTemplate("A", "double,T"));
REQUIRE_THAT(puml, IsClassTemplate("A", "long,U"));
REQUIRE_THAT(puml, !IsClassTemplate("A", "long,U"));
REQUIRE_THAT(puml, IsClassTemplate("A", "long,T"));
REQUIRE_THAT(puml, IsClassTemplate("A", "long,bool"));
REQUIRE_THAT(puml, IsClassTemplate("A", "double,bool"));
@@ -53,10 +53,9 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsInstantiation(_A("A<T,P>"), _A("A<T,std::string>")));
REQUIRE_THAT(puml, IsInstantiation(_A("A<long,T>"), _A("A<long,float>")));
REQUIRE_THAT(puml, IsInstantiation(_A("A<long,T>"), _A("A<long,bool>")));
// TODO: Fix matching partial template specializations with differently
// named template paremeters
// REQUIRE_THAT(
// puml, IsInstantiation(_A("A<T,P>"), _A("A<long,T>")));
REQUIRE_THAT(puml, IsInstantiation(_A("A<T,P>"), _A("A<long,T>")));
REQUIRE_THAT(puml, !IsInstantiation(_A("A<long,T>"), _A("A<long,U>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("A<double,T>"), _A("A<double,float>")));
REQUIRE_THAT(
@@ -79,7 +78,8 @@ TEST_CASE("t00014", "[test-case][class]")
REQUIRE_THAT(puml, IsAggregation(_A("R"), _A("A<long,bool>"), "-bapair"));
REQUIRE_THAT(
puml, IsAggregation(_A("R"), _A("A<double,bool>"), "-aboolfloat"));
REQUIRE_THAT(puml, IsAssociation(_A("R"), _A("A<double,float>"), "-afloat"));
REQUIRE_THAT(
puml, IsAssociation(_A("R"), _A("A<double,float>"), "-afloat"));
REQUIRE_THAT(
puml, IsAggregation(_A("R"), _A("A<bool,std::string>"), "-boolstring"));
REQUIRE_THAT(puml,

View File

@@ -36,14 +36,14 @@ TEST_CASE("t00027", "[test-case][class]")
REQUIRE_THAT(puml, EndsWith("@enduml\n"));
REQUIRE_THAT(puml, IsAbstractClass(_A("Shape")));
REQUIRE_THAT(puml, IsAbstractClass(_A("ShapeDecorator")));
REQUIRE_THAT(puml, IsClassTemplate("Line", "T<>"));
REQUIRE_THAT(puml, IsClassTemplate("Text", "T<>"));
REQUIRE_THAT(puml, IsInstantiation(_A("Line<T<>>"), _A("Line<Color>")));
REQUIRE_THAT(puml, IsClassTemplate("Line", "T<>..."));
REQUIRE_THAT(puml, IsClassTemplate("Text", "T<>..."));
REQUIRE_THAT(puml, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("Line<T<>>"), _A("Line<Color,Weight>")));
REQUIRE_THAT(puml, IsInstantiation(_A("Text<T<>>"), _A("Text<Color>")));
puml, IsInstantiation(_A("Line<T<>...>"), _A("Line<Color,Weight>")));
REQUIRE_THAT(puml, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color>")));
REQUIRE_THAT(
puml, IsInstantiation(_A("Text<T<>>"), _A("Text<Color,Weight>")));
puml, IsInstantiation(_A("Text<T<>...>"), _A("Text<Color,Weight>")));
REQUIRE_THAT(
puml, IsAggregation(_A("Window"), _A("Line<Color,Weight>"), "+border"));