Skip to content

Commit f023e99

Browse files
committed
Fix clang-tidy warnings in tests
1 parent 046d890 commit f023e99

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

extras/tests/JsonDocument/assignment.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ TEST_CASE("JsonDocument assignment") {
6969
doc2 = std::move(doc1);
7070

7171
REQUIRE(doc2.as<std::string>() == "{\"hello\":\"world\"}");
72+
73+
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
7274
REQUIRE(doc1.as<std::string>() == "null");
7375
}
7476
REQUIRE(spyingAllocator.log() == AllocatorLog{

extras/tests/JsonDocument/constructor.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ TEST_CASE("JsonDocument constructor") {
4444
JsonDocument doc2(std::move(doc1));
4545

4646
REQUIRE(doc2.as<std::string>() == "The size of this string is 32!!");
47+
48+
// NOLINTNEXTLINE(clang-analyzer-cplusplus.Move)
4749
REQUIRE(doc1.as<std::string>() == "null");
4850
}
4951
REQUIRE(spyingAllocator.log() == AllocatorLog{

extras/tests/ResourceManager/StringBuilder.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ TEST_CASE("StringBuilder") {
116116
}
117117
}
118118

119-
static JsonString saveString(StringBuilder& builder, const char* s) {
119+
static VariantData saveString(StringBuilder& builder, const char* s) {
120120
VariantData data;
121121
builder.startString();
122122
builder.append(s);
123123
builder.save(&data);
124-
return data.asString();
124+
return data;
125125
}
126126

127127
TEST_CASE("StringBuilder::save() deduplicates strings") {
@@ -134,9 +134,9 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
134134
auto s2 = saveString(builder, "world");
135135
auto s3 = saveString(builder, "hello");
136136

137-
REQUIRE(s1 == "hello");
138-
REQUIRE(s2 == "world");
139-
REQUIRE(+s1.c_str() == +s3.c_str()); // same address
137+
REQUIRE(s1.asString() == "hello");
138+
REQUIRE(s2.asString() == "world");
139+
REQUIRE(+s1.asString().c_str() == +s3.asString().c_str()); // same address
140140

141141
REQUIRE(spy.log() ==
142142
AllocatorLog{
@@ -152,9 +152,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
152152
auto s1 = saveString(builder, "hello world");
153153
auto s2 = saveString(builder, "hello");
154154

155-
REQUIRE(s1 == "hello world");
156-
REQUIRE(s2 == "hello");
157-
REQUIRE(+s2.c_str() != +s1.c_str()); // different address
155+
REQUIRE(s1.asString() == "hello world");
156+
REQUIRE(s2.asString() == "hello");
157+
REQUIRE(+s2.asString().c_str() !=
158+
+s1.asString().c_str()); // different address
158159

159160
REQUIRE(spy.log() ==
160161
AllocatorLog{
@@ -169,9 +170,10 @@ TEST_CASE("StringBuilder::save() deduplicates strings") {
169170
auto s1 = saveString(builder, "hello world");
170171
auto s2 = saveString(builder, "worl");
171172

172-
REQUIRE(s1 == "hello world");
173-
REQUIRE(s2 == "worl");
174-
REQUIRE(s2.c_str() != s1.c_str()); // different address
173+
REQUIRE(s1.asString() == "hello world");
174+
REQUIRE(s2.asString() == "worl");
175+
REQUIRE(s2.asString().c_str() !=
176+
s1.asString().c_str()); // different address
175177

176178
REQUIRE(spy.log() ==
177179
AllocatorLog{

0 commit comments

Comments
 (0)