MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / test_findallfields

Function test_findallfields

tests/proto.cc:183–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

181}
182
183static void test_findallfields(void)
184{
185 std::string s = R"M(
186 i64: -1
187 i32: -2
188 u64: 3
189 u32: 4
190 d: 5.5
191 f: 6.7
192 m {
193 s: "string"
194 }
195 r {
196 s: "val2"
197 }
198 r {
199 s: "val3"
200 }
201 secondoption {
202 s: "2"
203 }
204 )M";
205
206 TestProto proto;
207 if (!google::protobuf::TextFormat::MergeFromString(cleanup(s), &proto))
208 error("couldn't load test proto");
209
210 auto fields = findAllProtoFields(&proto);
211 std::vector<std::string> fieldNames;
212 for (const auto& e : fields)
213 fieldNames.push_back(e.path());
214 std::ranges::sort(fieldNames, doj::alphanum_less<std::string>());
215
216 AssertThat(fieldNames,
217 Equals(std::vector<std::string>{"d",
218 "f",
219 "i32",
220 "i64",
221 "m.s",
222 "r[0].s",
223 "r[1].s",
224 "secondoption.s",
225 "u32",
226 "u64"}));
227}
228
229static void test_rendering(void)
230{

Callers 1

mainFunction · 0.85

Calls 4

errorFunction · 0.85
findAllProtoFieldsFunction · 0.85
cleanupFunction · 0.70
push_backMethod · 0.45

Tested by

no test coverage detected