Skip to content

Commit df8db6a

Browse files
committed
fix: unit test with identical results using visitor
1 parent 0906b28 commit df8db6a

File tree

10 files changed

+406
-95
lines changed

10 files changed

+406
-95
lines changed

include/ClientGenerator.h

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,39 +67,46 @@ class [[nodiscard("unnecessary construction")]] Generator
6767
void outputResponseFieldVisitorStates(std::ostream& sourceFile,
6868
const ResponseField& responseField, std::string_view parent = {}) const noexcept;
6969
void outputResponseFieldVisitorAddValue(std::ostream& sourceFile,
70-
const ResponseField& responseField, std::string_view parentState = {},
71-
std::string_view parentAccessor = {}, std::string_view parentCppType = {}) const noexcept;
70+
const ResponseField& responseField, bool arrayElement = false,
71+
std::string_view parentState = {}, std::string_view parentAccessor = {},
72+
std::string_view parentCppType = {}) const noexcept;
7273
void outputResponseFieldVisitorReserve(std::ostream& sourceFile,
7374
const ResponseField& responseField, std::string_view parentState = {},
7475
std::string_view parentAccessor = {}, std::string_view parentCppType = {}) const noexcept;
7576
void outputResponseFieldVisitorStartObject(std::ostream& sourceFile,
7677
const ResponseField& responseField, std::string_view parentState = {},
7778
std::string_view parentAccessor = {}, std::string_view parentCppType = {}) const noexcept;
7879
void outputResponseFieldVisitorAddMember(std::ostream& sourceFile,
79-
const ResponseFieldList& children, std::string_view parentState = {}) const noexcept;
80+
const ResponseFieldList& children, bool arrayElement = false,
81+
std::string_view parentState = {}) const noexcept;
8082
void outputResponseFieldVisitorEndObject(std::ostream& sourceFile,
81-
const ResponseField& responseField, std::string_view parentState = {}) const noexcept;
83+
const ResponseField& responseField, bool arrayElement = false,
84+
std::string_view parentState = {}) const noexcept;
8285
void outputResponseFieldVisitorStartArray(std::ostream& sourceFile,
8386
const ResponseField& responseField, std::string_view parentState = {},
8487
std::string_view parentAccessor = {}, std::string_view parentCppType = {}) const noexcept;
85-
void outputResponseFieldVisitorEndArray(std::ostream& sourceFile,
86-
const ResponseField& responseField, std::string_view parentState = {}) const noexcept;
87-
void outputResponseFieldVisitorAddNull(std::ostream& sourceFile,
88-
const ResponseField& responseField, std::string_view parentState = {},
89-
std::string_view parentAccessor = {}) const noexcept;
88+
void outputResponseFieldVisitorEndArray(std::ostream& sourceFilearrayElement,
89+
const ResponseField& responseField, bool arrayElement = false,
90+
std::string_view parentState = {}) const noexcept;
91+
void outputResponseFieldVisitorAddNull(std::ostream& sourceFilearrayElement,
92+
const ResponseField& responseField, bool arrayElement = false,
93+
std::string_view parentState = {}, std::string_view parentAccessor = {}) const noexcept;
9094
void outputResponseFieldVisitorAddMovedValue(std::ostream& sourceFile,
9195
const ResponseField& responseField, std::string_view movedCppType,
92-
std::string_view parentState = {}, std::string_view parentAccessor = {}) const noexcept;
96+
bool arrayElement = false, std::string_view parentState = {},
97+
std::string_view parentAccessor = {}) const noexcept;
9398
void outputResponseFieldVisitorAddString(
9499
std::ostream& sourceFile, const ResponseField& responseField) const noexcept;
95100
void outputResponseFieldVisitorAddEnum(std::ostream& sourceFile,
96-
const ResponseField& responseField, std::string_view parentState = {},
97-
std::string_view parentAccessor = {}, std::string_view parentCppType = {}) const noexcept;
101+
const ResponseField& responseField, bool arrayElement = false,
102+
std::string_view parentState = {}, std::string_view parentAccessor = {},
103+
std::string_view parentCppType = {}) const noexcept;
98104
void outputResponseFieldVisitorAddId(
99105
std::ostream& sourceFile, const ResponseField& responseField) const noexcept;
100106
void outputResponseFieldVisitorAddCopiedValue(std::ostream& sourceFile,
101107
const ResponseField& responseField, std::string_view copiedCppType,
102-
std::string_view parentState = {}, std::string_view parentAccessor = {}) const noexcept;
108+
bool arrayElement = false, std::string_view parentState = {},
109+
std::string_view parentAccessor = {}) const noexcept;
103110
void outputResponseFieldVisitorAddBool(
104111
std::ostream& sourceFile, const ResponseField& responseField) const noexcept;
105112
void outputResponseFieldVisitorAddInt(

samples/client/benchmark/TodayClient.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ struct ResponseVisitor::impl
195195
Member_appointments_pageInfo_hasNextPage,
196196
Member_appointments_edges,
197197
Member_appointments_edges_0,
198+
Member_appointments_edges_0_,
198199
Member_appointments_edges_0_node,
199200
Member_appointments_edges_0_node_id,
200201
Member_appointments_edges_0_node_when,
@@ -242,7 +243,7 @@ void ResponseVisitor::add_value([[maybe_unused]] std::shared_ptr<const response:
242243
break;
243244

244245
case impl::VisitorState::Member_appointments_edges_0_node:
245-
_pimpl->state = impl::VisitorState::Member_appointments_edges_0;
246+
_pimpl->state = impl::VisitorState::Member_appointments_edges_0_;
246247
_pimpl->response.appointments.edges->back()->node = ModifiedResponse<Response::appointments_AppointmentConnection::edges_AppointmentEdge::node_Appointment>::parse<TypeModifier::Nullable>(response::Value { *value });
247248
break;
248249

@@ -289,6 +290,7 @@ void ResponseVisitor::start_object()
289290
switch (_pimpl->state)
290291
{
291292
case impl::VisitorState::Member_appointments_edges_0:
293+
_pimpl->state = impl::VisitorState::Member_appointments_edges_0_;
292294
_pimpl->response.appointments.edges->push_back(std::make_optional<Response::appointments_AppointmentConnection::edges_AppointmentEdge>({}));
293295
break;
294296

@@ -330,7 +332,7 @@ void ResponseVisitor::add_member([[maybe_unused]] std::string&& key)
330332
}
331333
break;
332334

333-
case impl::VisitorState::Member_appointments_edges_0:
335+
case impl::VisitorState::Member_appointments_edges_0_:
334336
if (key == "node"sv)
335337
{
336338
_pimpl->state = impl::VisitorState::Member_appointments_edges_0_node;
@@ -370,9 +372,17 @@ void ResponseVisitor::end_object()
370372
break;
371373

372374
case impl::VisitorState::Member_appointments_edges_0_node:
375+
_pimpl->state = impl::VisitorState::Member_appointments_edges_0_;
376+
break;
377+
378+
case impl::VisitorState::Member_appointments_edges_0_:
373379
_pimpl->state = impl::VisitorState::Member_appointments_edges_0;
374380
break;
375381

382+
case impl::VisitorState::Member_appointments:
383+
_pimpl->state = impl::VisitorState::Start;
384+
break;
385+
376386
default:
377387
break;
378388
}
@@ -414,7 +424,7 @@ void ResponseVisitor::add_null()
414424
break;
415425

416426
case impl::VisitorState::Member_appointments_edges_0_node:
417-
_pimpl->state = impl::VisitorState::Member_appointments_edges_0;
427+
_pimpl->state = impl::VisitorState::Member_appointments_edges_0_;
418428
_pimpl->response.appointments.edges->back()->node = std::nullopt;
419429
break;
420430

0 commit comments

Comments
 (0)