@@ -201,8 +201,7 @@ TableIdentifier CreateTableIdentifier(std::vector<std::string> ns, std::string n
201201} // namespace
202202
203203TEST (JsonRestTest, ListNamespaceResponse) {
204- ListNamespaceResponse r;
205- r.namespaces = {{" db1" }, {" db2" , " s1" }, {" db3" , " s2" , " sub" }};
204+ ListNamespaceResponse r{.namespaces = {{" db1" }, {" db2" , " s1" }, {" db3" , " s2" , " sub" }}};
206205
207206 nlohmann::json golden = R"( {
208207 "namespaces": [
@@ -220,10 +219,10 @@ TEST(JsonRestTest, ListTableResponseIgnoreUnknown) {
220219}
221220
222221TEST (JsonRestTest, CreateNamespaceRequest) {
223- CreateNamespaceRequest req;
224- req .namespaces = {" db1" , " schema1" };
225- req .properties = std::unordered_map<std::string, std::string>{
226- {" owner" , " user1" }, {" location" , " /warehouse/db1/schema1" }};
222+ CreateNamespaceRequest req{
223+ .namespaces = {" db1" , " schema1" },
224+ .properties = std::unordered_map<std::string, std::string>{
225+ {" owner" , " user1" }, {" location" , " /warehouse/db1/schema1" } }};
227226
228227 nlohmann::json golden = R"( {
229228 "namespaces": ["db1","schema1"],
@@ -235,9 +234,7 @@ TEST(JsonRestTest, CreateNamespaceRequest) {
235234}
236235
237236TEST (JsonRestTest, CreateNamespaceRequestMinimal) {
238- CreateNamespaceRequest req;
239- req.namespaces = {" db_only" };
240- req.properties = std::nullopt ;
237+ CreateNamespaceRequest req{.namespaces = {" db_only" }, .properties = std::nullopt };
241238
242239 nlohmann::json golden = R"( {
243240 "namespaces": ["db_only"]
@@ -247,9 +244,9 @@ TEST(JsonRestTest, CreateNamespaceRequestMinimal) {
247244}
248245
249246TEST (JsonRestTest, CreateNamespaceResponse) {
250- CreateNamespaceResponse resp;
251- resp .namespaces = {" db1" , " s1" };
252- resp .properties = std::unordered_map<std::string, std::string>{{" created" , " true" }};
247+ CreateNamespaceResponse resp{
248+ .namespaces = {" db1" , " s1" },
249+ .properties = std::unordered_map<std::string, std::string>{{" created" , " true" } }};
253250
254251 nlohmann::json golden = R"( {
255252 "namespaces": ["db1","s1"],
@@ -261,9 +258,7 @@ TEST(JsonRestTest, CreateNamespaceResponse) {
261258}
262259
263260TEST (JsonRestTest, CreateNamespaceResponseMinimal) {
264- CreateNamespaceResponse resp;
265- resp.namespaces = {" db1" , " s1" };
266- resp.properties = std::nullopt ;
261+ CreateNamespaceResponse resp{.namespaces = {" db1" , " s1" }, .properties = std::nullopt };
267262 nlohmann::json golden = R"( {"namespaces":["db1","s1"]})" _json;
268263 TestJsonConversion (resp, golden);
269264}
@@ -274,10 +269,10 @@ TEST(JsonRestTest, CreateNamespaceResponseIgnoreUnknown) {
274269}
275270
276271TEST (JsonRestTest, GetNamespacePropertiesResponse) {
277- GetNamespacePropertiesResponse r;
278- r .namespaces = {" prod" , " analytics" };
279- r .properties = std::unordered_map<std::string, std::string>{{ " owner " , " team-analytics " },
280- {" retention" , " 90days" }};
272+ GetNamespacePropertiesResponse r{
273+ .namespaces = {" prod" , " analytics" },
274+ .properties = std::unordered_map<std::string, std::string>{
275+ { " owner " , " team-analytics " }, {" retention" , " 90days" } }};
281276
282277 nlohmann::json golden = R"( {
283278 "namespaces": ["prod","analytics"],
@@ -290,9 +285,9 @@ TEST(JsonRestTest, GetNamespacePropertiesResponse) {
290285
291286TEST (JsonRestTest, UpdateNamespacePropertiesRequestVariants) {
292287 // both
293- UpdateNamespacePropertiesRequest both;
294- both .removals = std::vector<std::string>{" k1" , " k2" };
295- both .updates = std::unordered_map<std::string, std::string>{{" a" , " b" }};
288+ UpdateNamespacePropertiesRequest both{
289+ .removals = std::vector<std::string>{" k1" , " k2" },
290+ .updates = std::unordered_map<std::string, std::string>{{" a" , " b" } }};
296291
297292 nlohmann::json g_both = R"( {
298293 "removals": ["k1","k2"],
@@ -302,19 +297,18 @@ TEST(JsonRestTest, UpdateNamespacePropertiesRequestVariants) {
302297 TestJsonRoundTrip (both);
303298
304299 // removals only
305- UpdateNamespacePropertiesRequest rm;
306- rm.removals = std::vector<std::string>{" k" };
307- rm.updates = std::nullopt ;
300+ UpdateNamespacePropertiesRequest rm{.removals = std::vector<std::string>{" k" },
301+ .updates = std::nullopt };
308302
309303 nlohmann::json g_rm = R"( {
310304 "removals": ["k"]
311305 })" _json;
312306 TestJsonConversion (rm, g_rm);
313307
314308 // updates only
315- UpdateNamespacePropertiesRequest up;
316- up .removals = std::nullopt ;
317- up .updates = std::unordered_map<std::string, std::string>{{" x" , " y" }};
309+ UpdateNamespacePropertiesRequest up{
310+ .removals = std::nullopt ,
311+ .updates = std::unordered_map<std::string, std::string>{{" x" , " y" } }};
318312
319313 nlohmann::json g_up = R"( {
320314 "updates": {"x":"y"}
@@ -323,10 +317,9 @@ TEST(JsonRestTest, UpdateNamespacePropertiesRequestVariants) {
323317}
324318
325319TEST (JsonRestTest, UpdateNamespacePropsResponseWithAndWithoutMissing) {
326- UpdateNamespacePropsResponse full;
327- full.updated = {" u1" , " u2" };
328- full.removed = {" r1" };
329- full.missing = std::vector<std::string>{" m1" };
320+ UpdateNamespacePropsResponse full{.updated = {" u1" , " u2" },
321+ .removed = {" r1" },
322+ .missing = std::vector<std::string>{" m1" }};
330323
331324 nlohmann::json g_full = R"( {
332325 "updated": ["u1","u2"],
@@ -336,10 +329,8 @@ TEST(JsonRestTest, UpdateNamespacePropsResponseWithAndWithoutMissing) {
336329 TestJsonConversion (full, g_full);
337330 TestJsonRoundTrip (full);
338331
339- UpdateNamespacePropsResponse minimal;
340- minimal.updated = {" u" };
341- minimal.removed = {};
342- minimal.missing = std::nullopt ;
332+ UpdateNamespacePropsResponse minimal{
333+ .updated = {" u" }, .removed = {}, .missing = std::nullopt };
343334
344335 nlohmann::json g_min = R"( {
345336 "updated": ["u"],
@@ -350,9 +341,9 @@ TEST(JsonRestTest, UpdateNamespacePropsResponseWithAndWithoutMissing) {
350341
351342TEST (JsonRestTest, ListTableResponseWithAndWithoutIdentifiers) {
352343 // with identifiers
353- ListTableResponse r;
354- r. identifiers = std::vector<TableIdentifier>{ CreateTableIdentifier ({" db1" }, " t1" ),
355- CreateTableIdentifier ({" db2" , " s" }, " t2" )};
344+ ListTableResponse r{. identifiers = std::vector<TableIdentifier>{
345+ CreateTableIdentifier ({" db1" }, " t1" ),
346+ CreateTableIdentifier ({" db2" , " s" }, " t2" )} };
356347
357348 nlohmann::json g_with = R"( {
358349 "identifiers": [
@@ -365,17 +356,15 @@ TEST(JsonRestTest, ListTableResponseWithAndWithoutIdentifiers) {
365356 TestJsonRoundTrip (r);
366357
367358 // without identifiers
368- ListTableResponse empty;
369- empty.identifiers = std::nullopt ;
359+ ListTableResponse empty{.identifiers = std::nullopt };
370360
371361 nlohmann::json g_empty = R"( {})" _json;
372362 TestJsonConversion (empty, g_empty);
373363}
374364
375365TEST (JsonRestTest, RenameTableRequestBasicAndDecodeGolden) {
376- RenameTableRequest req;
377- req.source = CreateTableIdentifier ({" old" }, " t0" );
378- req.destination = CreateTableIdentifier ({" new" , " s" }, " t1" );
366+ RenameTableRequest req{.source = CreateTableIdentifier ({" old" }, " t0" ),
367+ .destination = CreateTableIdentifier ({" new" , " s" }, " t1" )};
379368
380369 nlohmann::json golden = R"( {
381370 "source": {"namespace":["old"], "name":"t0"},
@@ -397,10 +386,8 @@ TEST(JsonRestTest, RenameTableRequestBasicAndDecodeGolden) {
397386}
398387
399388TEST (JsonRestTest, RegisterTableRequestWithAndWithoutOverwrite) {
400- RegisterTableRequest r1;
401- r1.name = " t" ;
402- r1.metadata_location = " s3://m/v1.json" ;
403- r1.overwrite = true ;
389+ RegisterTableRequest r1{
390+ .name = " t" , .metadata_location = " s3://m/v1.json" , .overwrite = true };
404391
405392 nlohmann::json g1 = R"( {
406393 "name":"t",
@@ -410,10 +397,8 @@ TEST(JsonRestTest, RegisterTableRequestWithAndWithoutOverwrite) {
410397 TestJsonConversion (r1, g1);
411398 TestJsonRoundTrip (r1);
412399
413- RegisterTableRequest r2;
414- r2.name = " t2" ;
415- r2.metadata_location = " /tmp/m.json" ;
416- r2.overwrite = std::nullopt ;
400+ RegisterTableRequest r2{
401+ .name = " t2" , .metadata_location = " /tmp/m.json" , .overwrite = std::nullopt };
417402
418403 nlohmann::json g2 = R"( {
419404 "name":"t2",
@@ -445,15 +430,15 @@ TEST(JsonRestTest, CreateTableRequestFull) {
445430 NullOrder::kFirst );
446431 auto write_order = std::make_shared<SortOrder>(1 , std::vector<SortField>{sort_field});
447432
448- CreateTableRequest request;
449- request .name = " test_table" ;
450- request .location = " s3://bucket/warehouse/test_table" ;
451- request .schema = schema;
452- request .partition_spec = partition_spec;
453- request .write_order = write_order;
454- request .stage_create = true ;
455- request .properties = std::unordered_map<std::string, std::string>{
456- {" write.format.default" , " parquet" }, {" commit.retry.num-retries" , " 10" }};
433+ CreateTableRequest request{
434+ .name = " test_table" ,
435+ .location = " s3://bucket/warehouse/test_table" ,
436+ .schema = schema,
437+ .partition_spec = partition_spec,
438+ .write_order = write_order,
439+ .stage_create = true ,
440+ .properties = std::unordered_map<std::string, std::string>{
441+ {" write.format.default" , " parquet" }, {" commit.retry.num-retries" , " 10" } }};
457442
458443 TestJsonRoundTrip (request);
459444}
@@ -462,14 +447,13 @@ TEST(JsonRestTest, CreateTableRequestMinimal) {
462447 auto schema = std::make_shared<Schema>(
463448 std::vector<SchemaField>{SchemaField (1 , " id" , iceberg::int64 (), false )}, 0 );
464449
465- CreateTableRequest request;
466- request.name = " minimal_table" ;
467- request.location = std::nullopt ;
468- request.schema = schema;
469- request.partition_spec = nullptr ;
470- request.write_order = nullptr ;
471- request.stage_create = std::nullopt ;
472- request.properties = std::nullopt ;
450+ CreateTableRequest request{.name = " minimal_table" ,
451+ .location = std::nullopt ,
452+ .schema = schema,
453+ .partition_spec = nullptr ,
454+ .write_order = nullptr ,
455+ .stage_create = std::nullopt ,
456+ .properties = std::nullopt };
473457
474458 TestJsonRoundTrip (request);
475459
@@ -498,12 +482,11 @@ TEST(JsonRestTest, CreateTableRequestMissingRequiredFields) {
498482}
499483
500484TEST (JsonRestTest, CreateTableResponse) {
501- CreateTableResponse r;
502- r.metadata_location = " s3://bucket/metadata/v1.json" ;
503- r.metadata = CreateTableMetadata ();
504- r.config = std::unordered_map<std::string, std::string>{
505- {" catalog-impl" , " org.apache.iceberg.rest.RESTCatalog" },
506- {" warehouse" , " s3://bucket/warehouse" }};
485+ CreateTableResponse r{.metadata_location = " s3://bucket/metadata/v1.json" ,
486+ .metadata = CreateTableMetadata (),
487+ .config = std::unordered_map<std::string, std::string>{
488+ {" catalog-impl" , " org.apache.iceberg.rest.RESTCatalog" },
489+ {" warehouse" , " s3://bucket/warehouse" }}};
507490 TestJsonRoundTrip (r);
508491 auto j = ToJson (r);
509492 EXPECT_TRUE (j.contains (" metadata-location" ));
@@ -513,10 +496,9 @@ TEST(JsonRestTest, CreateTableResponse) {
513496}
514497
515498TEST (JsonRestTest, CreateTableResponseMinimal) {
516- CreateTableResponse r;
517- r.metadata_location = std::nullopt ;
518- r.metadata = CreateTableMetadata ();
519- r.config = std::nullopt ;
499+ CreateTableResponse r{.metadata_location = std::nullopt ,
500+ .metadata = CreateTableMetadata (),
501+ .config = std::nullopt };
520502 TestJsonRoundTrip (r);
521503 auto j = ToJson (r);
522504 EXPECT_FALSE (j.contains (" metadata-location" ));
@@ -525,19 +507,17 @@ TEST(JsonRestTest, CreateTableResponseMinimal) {
525507}
526508
527509TEST (JsonRestTest, RegisterTableResponse) {
528- RegisterTableResponse r;
529- r.metadata_location = " hdfs://nn/warehouse/table/metadata.json" ;
530- r.metadata = CreateTableMetadata ();
531- r.config = std::unordered_map<std::string, std::string>{
532- {" io-impl" , " org.apache.hadoop.fs.HdfsFileSystem" }};
510+ RegisterTableResponse r{.metadata_location = " hdfs://nn/warehouse/table/metadata.json" ,
511+ .metadata = CreateTableMetadata (),
512+ .config = std::unordered_map<std::string, std::string>{
513+ {" io-impl" , " org.apache.hadoop.fs.HdfsFileSystem" }}};
533514 TestJsonRoundTrip (r);
534515}
535516
536517TEST (JsonRestTest, LoadTableResponse) {
537- LoadTableResponse r;
538- r.metadata_location = std::nullopt ;
539- r.metadata = CreateTableMetadata ();
540- r.config = std::nullopt ;
518+ LoadTableResponse r{.metadata_location = std::nullopt ,
519+ .metadata = CreateTableMetadata (),
520+ .config = std::nullopt };
541521 TestJsonRoundTrip (r);
542522 auto j = ToJson (r);
543523 EXPECT_FALSE (j.contains (" metadata-location" ));
@@ -546,12 +526,11 @@ TEST(JsonRestTest, LoadTableResponse) {
546526}
547527
548528TEST (JsonRestTest, LoadTableResponseFull) {
549- LoadTableResponse r;
550- r.metadata_location = " s3://bucket/warehouse/table/metadata/v2.json" ;
551- r.metadata = CreateTableMetadata ();
552- r.config = std::unordered_map<std::string, std::string>{
553- {" io-impl" , " org.apache.iceberg.aws.s3.S3FileIO" },
554- {" warehouse" , " s3://bucket/warehouse" }};
529+ LoadTableResponse r{.metadata_location = " s3://bucket/warehouse/table/metadata/v2.json" ,
530+ .metadata = CreateTableMetadata (),
531+ .config = std::unordered_map<std::string, std::string>{
532+ {" io-impl" , " org.apache.iceberg.aws.s3.S3FileIO" },
533+ {" warehouse" , " s3://bucket/warehouse" }}};
555534 TestJsonRoundTrip (r);
556535 auto j = ToJson (r);
557536 EXPECT_TRUE (j.contains (" metadata-location" ));
@@ -584,19 +563,18 @@ TEST(JsonRestTest, RenameTableRequestInvalidNested) {
584563}
585564
586565TEST (JsonRestBoundaryTest, VeryLongStrings) {
587- CreateNamespaceRequest request;
588566 std::string long_string (10000 , ' a' );
589- request.namespaces = {long_string};
590- request.properties =
591- std::unordered_map<std::string, std::string>{{long_string, long_string}};
567+ CreateNamespaceRequest request{
568+ .namespaces = {long_string},
569+ .properties =
570+ std::unordered_map<std::string, std::string>{{long_string, long_string}}};
592571
593572 TestJsonRoundTrip (request);
594573}
595574
596575TEST (JsonRestBoundaryTest, EmptyCollections) {
597- CreateNamespaceRequest request;
598- request.namespaces = {" ns" };
599- request.properties = std::unordered_map<std::string, std::string>{};
576+ CreateNamespaceRequest request{
577+ .namespaces = {" ns" }, .properties = std::unordered_map<std::string, std::string>{}};
600578
601579 auto json = ToJson (request);
602580 EXPECT_TRUE (json.contains (" properties" ));
0 commit comments