fix clang tidy warnings and add nolint for certain occaisons
This commit is contained in:
parent
47c3eb785e
commit
5f822d863f
@ -36,92 +36,95 @@ using nlohmann::json;
|
|||||||
|
|
||||||
namespace persons
|
namespace persons
|
||||||
{
|
{
|
||||||
#define PERSON_CLASS_BODY(ClassName, Visibility) \
|
#define PERSON_CLASS_BODY(ClassName, Visibility) \
|
||||||
Visibility: \
|
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
|
||||||
std::string name = ""; \
|
Visibility: \
|
||||||
int age = 0; \
|
/* NOLINTNEXTLINE(readability-redundant-string-init): collides with -Weffc++ */ \
|
||||||
json metadata = nullptr; \
|
std::string name = ""; \
|
||||||
public: \
|
int age = 0; \
|
||||||
bool operator==(const ClassName& rhs) const \
|
json metadata = nullptr; \
|
||||||
{ \
|
public: \
|
||||||
return name == rhs.name && age == rhs.age && metadata == rhs.metadata; \
|
bool operator==(const ClassName& rhs) const \
|
||||||
} \
|
{ \
|
||||||
ClassName() = default; \
|
return name == rhs.name && age == rhs.age && metadata == rhs.metadata; \
|
||||||
ClassName(std::string name_, int age_, json metadata_) \
|
} \
|
||||||
: name(std::move(name_)) \
|
ClassName() = default; \
|
||||||
, age(age_) \
|
ClassName(std::string name_, int age_, json metadata_) \
|
||||||
, metadata(std::move(metadata_)) \
|
: name(std::move(name_)) \
|
||||||
{} \
|
, age(age_) \
|
||||||
std::string getName() const \
|
, metadata(std::move(metadata_)) \
|
||||||
{ \
|
{} \
|
||||||
return name; \
|
std::string getName() const \
|
||||||
} \
|
{ \
|
||||||
int getAge() const \
|
return name; \
|
||||||
{ \
|
} \
|
||||||
return age; \
|
int getAge() const \
|
||||||
} \
|
{ \
|
||||||
json getMetadata() const \
|
return age; \
|
||||||
{ \
|
} \
|
||||||
return metadata; \
|
json getMetadata() const \
|
||||||
|
{ \
|
||||||
|
return metadata; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ALPHABET_CLASS_BODY(ClassName, Visibility) \
|
#define ALPHABET_CLASS_BODY(ClassName, Visibility) \
|
||||||
public: \
|
public: \
|
||||||
bool operator==(const ClassName& other) const \
|
bool operator==(const ClassName& other) const \
|
||||||
{ \
|
{ \
|
||||||
return a == other.a && \
|
return a == other.a && \
|
||||||
b == other.b && \
|
b == other.b && \
|
||||||
c == other.c && \
|
c == other.c && \
|
||||||
d == other.d && \
|
d == other.d && \
|
||||||
e == other.e && \
|
e == other.e && \
|
||||||
f == other.f && \
|
f == other.f && \
|
||||||
g == other.g && \
|
g == other.g && \
|
||||||
h == other.h && \
|
h == other.h && \
|
||||||
i == other.i && \
|
i == other.i && \
|
||||||
j == other.j && \
|
j == other.j && \
|
||||||
k == other.k && \
|
k == other.k && \
|
||||||
l == other.l && \
|
l == other.l && \
|
||||||
m == other.m && \
|
m == other.m && \
|
||||||
n == other.n && \
|
n == other.n && \
|
||||||
o == other.o && \
|
o == other.o && \
|
||||||
p == other.p && \
|
p == other.p && \
|
||||||
q == other.q && \
|
q == other.q && \
|
||||||
r == other.r && \
|
r == other.r && \
|
||||||
s == other.s && \
|
s == other.s && \
|
||||||
t == other.t && \
|
t == other.t && \
|
||||||
u == other.u && \
|
u == other.u && \
|
||||||
v == other.v && \
|
v == other.v && \
|
||||||
w == other.w && \
|
w == other.w && \
|
||||||
x == other.x && \
|
x == other.x && \
|
||||||
y == other.y && \
|
y == other.y && \
|
||||||
z == other.z; \
|
z == other.z; \
|
||||||
} \
|
} \
|
||||||
Visibility: \
|
/* NOLINTNEXTLINE(bugprone-macro-parentheses) */ \
|
||||||
int a = 0; \
|
Visibility: \
|
||||||
int b = 0; \
|
int a = 0; \
|
||||||
int c = 0; \
|
int b = 0; \
|
||||||
int d = 0; \
|
int c = 0; \
|
||||||
int e = 0; \
|
int d = 0; \
|
||||||
int f = 0; \
|
int e = 0; \
|
||||||
int g = 0; \
|
int f = 0; \
|
||||||
int h = 0; \
|
int g = 0; \
|
||||||
int i = 0; \
|
int h = 0; \
|
||||||
int j = 0; \
|
int i = 0; \
|
||||||
int k = 0; \
|
int j = 0; \
|
||||||
int l = 0; \
|
int k = 0; \
|
||||||
int m = 0; \
|
int l = 0; \
|
||||||
int n = 0; \
|
int m = 0; \
|
||||||
int o = 0; \
|
int n = 0; \
|
||||||
int p = 0; \
|
int o = 0; \
|
||||||
int q = 0; \
|
int p = 0; \
|
||||||
int r = 0; \
|
int q = 0; \
|
||||||
int s = 0; \
|
int r = 0; \
|
||||||
int t = 0; \
|
int s = 0; \
|
||||||
int u = 0; \
|
int t = 0; \
|
||||||
int v = 0; \
|
int u = 0; \
|
||||||
int w = 0; \
|
int v = 0; \
|
||||||
int x = 0; \
|
int w = 0; \
|
||||||
int y = 0; \
|
int x = 0; \
|
||||||
|
int y = 0; \
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
|
||||||
class person_with_private_data
|
class person_with_private_data
|
||||||
@ -218,8 +221,8 @@ struct TestTypePair
|
|||||||
using BasicJsonType = BasicJsonType_;
|
using BasicJsonType = BasicJsonType_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PERSON_TYPES_TO_TEST \
|
#define PERSON_TYPES_TO_TEST \
|
||||||
TestTypePair<persons::person_with_private_data>, \
|
TestTypePair<persons::person_with_private_data>, \
|
||||||
TestTypePair<persons::person_without_private_data_1>, \
|
TestTypePair<persons::person_without_private_data_1>, \
|
||||||
TestTypePair<persons::person_without_private_data_2>, \
|
TestTypePair<persons::person_without_private_data_2>, \
|
||||||
TestTypePair<persons::person_t_with_private_data>, \
|
TestTypePair<persons::person_t_with_private_data>, \
|
||||||
@ -242,11 +245,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
|
|||||||
std::string json_string;
|
std::string json_string;
|
||||||
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":1,\"name\":\"Erik\",\"metadata\":{\"haircuts\":2}}";
|
json_string = R"str({"age":1,"name":"Erik","metadata":{"haircuts":2}})str";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}";
|
json_string = R"str({"age":1,"metadata":{"haircuts":2},"name":"Erik"})str";
|
||||||
}
|
}
|
||||||
CHECK(json_t(p1).dump() == json_string);
|
CHECK(json_t(p1).dump() == json_string);
|
||||||
|
|
||||||
@ -286,11 +289,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
|
|||||||
std::string json_string;
|
std::string json_string;
|
||||||
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":0,\"name\":\"\",\"metadata\":null}";
|
json_string = R"str({"age":0,"name":"","metadata":null})str";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":0,\"metadata\":null,\"name\":\"\"}";
|
json_string = R"str({"age":0,"metadata":null,"name":""})str";
|
||||||
}
|
}
|
||||||
CHECK(json_t(p0).dump() == json_string);
|
CHECK(json_t(p0).dump() == json_string);
|
||||||
|
|
||||||
@ -298,11 +301,11 @@ TEST_CASE_TEMPLATE("Serialization/deserialization via NLOHMANN_DEFINE_TYPE_INTRU
|
|||||||
T p1("Erik", 1, {{"haircuts", 2}});
|
T p1("Erik", 1, {{"haircuts", 2}});
|
||||||
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
if (std::is_same<json_t, nlohmann::ordered_json>::value)
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":1,\"name\":\"Erik\",\"metadata\":{\"haircuts\":2}}";
|
json_string = R"str({"age":1,"name":"Erik","metadata":{"haircuts":2}})str";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_string = "{\"age\":1,\"metadata\":{\"haircuts\":2},\"name\":\"Erik\"}";
|
json_string = R"str({"age":1,"metadata":{"haircuts":2},"name":"Erik"})str";
|
||||||
}
|
}
|
||||||
CHECK(json_t(p1).dump() == json_string);
|
CHECK(json_t(p1).dump() == json_string);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user