2023-05-26 13:52:09 +01:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
|
|
|
|
#include "oi/type_graph/NameGen.h"
|
|
|
|
#include "oi/type_graph/Types.h"
|
2023-05-31 14:26:46 +01:00
|
|
|
#include "test/type_graph_utils.h"
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
using namespace type_graph;
|
|
|
|
|
|
|
|
TEST(NameGenTest, ClassParams) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myclass = Class{2, Class::Kind::Struct, "MyClass<MyParam, MyParam>", 13};
|
2023-07-05 10:33:44 +01:00
|
|
|
myclass.templateParams.push_back(myparam1);
|
|
|
|
myclass.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_1");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_2");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ClassContainerParam) {
|
2023-07-04 16:55:10 +01:00
|
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
2023-05-26 13:52:09 +01:00
|
|
|
auto myparam = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
myparam.templateParams.push_back(myint);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myclass = Class{0, Class::Kind::Struct, "MyClass", 13};
|
2023-07-05 10:33:44 +01:00
|
|
|
myclass.templateParams.push_back(myparam);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(myparam.name(), "std::vector<int32_t>");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ClassParents) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparent1 = Class{0, Class::Kind::Struct, "MyParent", 13};
|
|
|
|
auto myparent2 = Class{1, Class::Kind::Struct, "MyParent", 13};
|
|
|
|
auto myclass = Class{2, Class::Kind::Struct, "MyClass", 13};
|
2023-07-05 10:33:44 +01:00
|
|
|
myclass.parents.push_back(Parent{myparent1, 0});
|
|
|
|
myclass.parents.push_back(Parent{myparent2, 0});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
|
|
|
EXPECT_EQ(myparent1.name(), "MyParent_1");
|
|
|
|
EXPECT_EQ(myparent2.name(), "MyParent_2");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ClassMembers) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto mymember1 = Class{0, Class::Kind::Struct, "MyMember", 13};
|
|
|
|
auto mymember2 = Class{1, Class::Kind::Struct, "MyMember", 13};
|
|
|
|
auto myclass = Class{2, Class::Kind::Struct, "MyClass", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
// A class may end up with members sharing a name after flattening
|
2023-07-05 10:33:44 +01:00
|
|
|
myclass.members.push_back(Member{mymember1, "mem", 0});
|
|
|
|
myclass.members.push_back(Member{mymember2, "mem", 0});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
|
|
|
EXPECT_EQ(myclass.members[0].name, "mem_0");
|
|
|
|
EXPECT_EQ(myclass.members[1].name, "mem_1");
|
|
|
|
EXPECT_EQ(mymember1.name(), "MyMember_1");
|
|
|
|
EXPECT_EQ(mymember2.name(), "MyMember_2");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ClassChildren) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto mychild1 = Class{0, Class::Kind::Struct, "MyChild", 13};
|
|
|
|
auto mychild2 = Class{1, Class::Kind::Struct, "MyChild", 13};
|
|
|
|
auto myclass = Class{2, Class::Kind::Struct, "MyClass", 13};
|
2023-07-04 16:55:10 +01:00
|
|
|
myclass.children.push_back(mychild1);
|
|
|
|
myclass.children.push_back(mychild2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
|
|
|
EXPECT_EQ(mychild1.name(), "MyChild_1");
|
|
|
|
EXPECT_EQ(mychild2.name(), "MyChild_2");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ContainerParams) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam1);
|
|
|
|
mycontainer.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer});
|
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_0, MyParam_1>");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ContainerParamsDuplicates) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam = Class{0, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam);
|
|
|
|
mycontainer.templateParams.push_back(myparam);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer});
|
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam.name(), "MyParam_0");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_0, MyParam_0>");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ContainerParamsDuplicatesDeep) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam = Class{0, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer1 = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer1.templateParams.push_back(myparam);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer2 = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer2.templateParams.push_back(myparam);
|
|
|
|
mycontainer2.templateParams.push_back(mycontainer1);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer2});
|
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam.name(), "MyParam_0");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer1.name(), "std::vector<MyParam_0>");
|
|
|
|
EXPECT_EQ(mycontainer2.name(),
|
|
|
|
"std::vector<MyParam_0, std::vector<MyParam_0>>");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ContainerParamsDuplicatesAcrossContainers) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam3 = Class{2, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer1 = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer1.templateParams.push_back(myparam1);
|
|
|
|
mycontainer1.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer2 = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer2.templateParams.push_back(myparam2);
|
|
|
|
mycontainer2.templateParams.push_back(myparam3);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer1, mycontainer2});
|
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
|
|
|
EXPECT_EQ(myparam3.name(), "MyParam_2");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer1.name(), "std::vector<MyParam_0, MyParam_1>");
|
|
|
|
EXPECT_EQ(mycontainer2.name(), "std::vector<MyParam_1, MyParam_2>");
|
|
|
|
}
|
|
|
|
|
2023-05-31 12:40:15 +01:00
|
|
|
TEST(NameGenTest, ContainerParamsConst) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyConstParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-31 12:40:15 +01:00
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
|
|
|
mycontainer.templateParams.push_back(
|
2023-07-05 10:33:44 +01:00
|
|
|
TemplateParam{myparam1, {Qualifier::Const}});
|
|
|
|
mycontainer.templateParams.push_back(TemplateParam{myparam2});
|
2023-05-31 12:40:15 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer});
|
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyConstParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
2023-05-31 12:40:15 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<const MyConstParam_0, MyParam_1>");
|
|
|
|
}
|
|
|
|
|
2023-06-23 14:50:10 +01:00
|
|
|
TEST(NameGenTest, ContainerNoParams) {
|
|
|
|
auto mycontainer = getVector();
|
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer});
|
|
|
|
|
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector");
|
|
|
|
}
|
|
|
|
|
2023-06-23 16:56:39 +01:00
|
|
|
TEST(NameGenTest, ContainerParamsValue) {
|
|
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
|
|
|
auto myenum = Enum{"MyEnum", 4};
|
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
|
|
|
mycontainer.templateParams.push_back(TemplateParam{"123"});
|
|
|
|
mycontainer.templateParams.push_back(TemplateParam{"MyEnum::OptionC"});
|
|
|
|
|
|
|
|
NameGen nameGen;
|
|
|
|
nameGen.generateNames({mycontainer});
|
|
|
|
|
|
|
|
EXPECT_EQ(myint.name(), "int32_t");
|
|
|
|
EXPECT_EQ(myenum.name(), "MyEnum");
|
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<123, MyEnum::OptionC>");
|
|
|
|
}
|
|
|
|
|
2023-05-26 13:52:09 +01:00
|
|
|
TEST(NameGenTest, Array) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam1);
|
|
|
|
mycontainer.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-05 10:33:44 +01:00
|
|
|
auto myarray = Array{2, mycontainer, 5};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myarray});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_0, MyParam_1>");
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myarray.name(), "OIArray<std::vector<MyParam_0, MyParam_1>, 5>");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, Typedef) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam1);
|
|
|
|
mycontainer.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-05 10:33:44 +01:00
|
|
|
auto mytypedef = Typedef{2, "MyTypedef", mycontainer};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({mytypedef});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_1");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_2");
|
2023-05-30 17:45:51 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_1, MyParam_2>");
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(mytypedef.name(), "MyTypedef_0");
|
2023-05-30 17:45:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, TypedefAliasTemplate) {
|
2023-07-04 16:55:10 +01:00
|
|
|
auto myint = Primitive{Primitive::Kind::Int32};
|
2023-07-05 10:33:44 +01:00
|
|
|
auto mytypedef = Typedef{0, "MyTypedef<ParamA, ParamB>", myint};
|
2023-05-30 17:45:51 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({mytypedef});
|
2023-05-30 17:45:51 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(mytypedef.name(), "MyTypedef_0");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, Pointer) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam1);
|
|
|
|
mycontainer.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-05 10:33:44 +01:00
|
|
|
auto mypointer = Pointer{2, mycontainer};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({mypointer});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_0, MyParam_1>");
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(mypointer.name(), "std::vector<MyParam_0, MyParam_1>*");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
2023-05-31 14:49:47 +01:00
|
|
|
TEST(NameGenTest, Dummy) {
|
2023-07-04 16:55:10 +01:00
|
|
|
auto dummy = Dummy{12, 34};
|
2023-05-31 14:49:47 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({dummy});
|
2023-05-31 14:49:47 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(dummy.name(), "DummySizedOperator<12, 34>");
|
2023-05-31 14:49:47 +01:00
|
|
|
}
|
|
|
|
|
2023-05-26 13:52:09 +01:00
|
|
|
TEST(NameGenTest, DummyAllocator) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myparam1 = Class{0, Class::Kind::Struct, "MyParam", 13};
|
|
|
|
auto myparam2 = Class{1, Class::Kind::Struct, "MyParam", 13};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
auto mycontainer = getVector();
|
2023-07-05 10:33:44 +01:00
|
|
|
mycontainer.templateParams.push_back(myparam1);
|
|
|
|
mycontainer.templateParams.push_back(myparam2);
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
auto myalloc = DummyAllocator{mycontainer, 12, 34};
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myalloc});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myparam1.name(), "MyParam_0");
|
|
|
|
EXPECT_EQ(myparam2.name(), "MyParam_1");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(mycontainer.name(), "std::vector<MyParam_0, MyParam_1>");
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myalloc.name(),
|
2023-05-31 14:49:47 +01:00
|
|
|
"DummyAllocator<std::vector<MyParam_0, MyParam_1>, 12, 34>");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, Cycle) {
|
2023-07-05 09:14:05 +01:00
|
|
|
auto classA = Class{0, Class::Kind::Class, "ClassA", 69};
|
|
|
|
auto classB = Class{1, Class::Kind::Class, "ClassB", 69};
|
2023-07-05 10:33:44 +01:00
|
|
|
auto ptrA = Pointer{2, classA};
|
|
|
|
classA.members.push_back(Member{classB, "b", 0});
|
|
|
|
classB.members.push_back(Member{ptrA, "a", 0});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({classA});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(classA.name(), "ClassA_0");
|
|
|
|
EXPECT_EQ(classB.name(), "ClassB_1");
|
2023-05-26 13:52:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST(NameGenTest, ContainerCycle) {
|
|
|
|
auto container = getVector();
|
2023-07-05 09:14:05 +01:00
|
|
|
auto myclass = Class{0, Class::Kind::Class, "MyClass", 69};
|
2023-07-05 10:33:44 +01:00
|
|
|
myclass.members.push_back(Member{container, "c", 0});
|
|
|
|
container.templateParams.push_back(TemplateParam{myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
|
|
|
NameGen nameGen;
|
2023-07-04 16:55:10 +01:00
|
|
|
nameGen.generateNames({myclass});
|
2023-05-26 13:52:09 +01:00
|
|
|
|
2023-07-04 16:55:10 +01:00
|
|
|
EXPECT_EQ(myclass.name(), "MyClass_0");
|
2023-05-26 13:52:09 +01:00
|
|
|
EXPECT_EQ(container.name(), "std::vector<MyClass_0>");
|
|
|
|
}
|