Skip to content

Commit 209424b

Browse files
authored
Merge pull request #1128 from joto/middle-tests-comment-cleanup
Clean up comments and variable names in middle test
2 parents ba8e800 + fe15e88 commit 209424b

File tree

1 file changed

+45
-46
lines changed

1 file changed

+45
-46
lines changed

tests/test-middle.cpp

Lines changed: 45 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ TEMPLATE_TEST_CASE("middle import", "", options_slim_default,
308308
}
309309

310310
/**
311-
* Check that the node is in the mid with the right id and location
311+
* Check that the node is in the mid with the right id and location.
312312
*/
313313
static void check_node(std::shared_ptr<middle_pgsql_t> const &mid,
314314
osmium::Node const &node)
@@ -321,7 +321,7 @@ static void check_node(std::shared_ptr<middle_pgsql_t> const &mid,
321321
REQUIRE(nodes[0].location() == node.location());
322322
}
323323

324-
/// Return true if the node with the specified id is not in the mid
324+
/// Return true if the node with the specified id is not in the mid.
325325
static bool no_node(std::shared_ptr<middle_pgsql_t> const &mid, osmid_t id)
326326
{
327327
test_buffer_t buffer;
@@ -330,7 +330,7 @@ static bool no_node(std::shared_ptr<middle_pgsql_t> const &mid, osmid_t id)
330330
return mid_q->nodes_get_list(&nodes) == 0;
331331
}
332332

333-
TEMPLATE_TEST_CASE("middle add, delete and update node", "",
333+
TEMPLATE_TEST_CASE("middle: add, delete and update node", "",
334334
options_slim_default, options_slim_dense_cache,
335335
options_flat_node_cache)
336336
{
@@ -339,7 +339,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
339339
testing::cleanup::file_t flatnode_cleaner{
340340
options.flat_node_file.get_value_or("")};
341341

342-
// Prepare a buffer with some nodes which we will add and change
342+
// Prepare a buffer with some nodes which we will add and change.
343343
test_buffer_t buffer;
344344
auto const &node10 = buffer.add_node_and_get(10, 1.0, 0.0);
345345
auto const &node11 = buffer.add_node_and_get(11, 1.1, 0.0);
@@ -349,7 +349,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
349349

350350
// Set up middle in "create" mode to get a cleanly initialized database
351351
// and add some nodes. Does this in its own scope so that the mid is
352-
// closed up properly.
352+
// closed properly.
353353
{
354354
auto mid = std::make_shared<middle_pgsql_t>(&options);
355355
mid->start();
@@ -363,10 +363,10 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
363363
mid->commit();
364364
}
365365

366-
// From now on use append mode to not destroy the data we just added
366+
// From now on use append mode to not destroy the data we just added.
367367
options.append = true;
368368

369-
SECTION("Check that added nodes are there and no others")
369+
SECTION("Added nodes are there and no others")
370370
{
371371
auto mid = std::make_shared<middle_pgsql_t>(&options);
372372
mid->start();
@@ -398,7 +398,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
398398
mid->commit();
399399
}
400400
{
401-
// Check with a new mid
401+
// Check with a new mid.
402402
auto mid = std::make_shared<middle_pgsql_t>(&options);
403403
mid->start();
404404

@@ -411,7 +411,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
411411
}
412412
}
413413

414-
SECTION("Change (delete and set) existing node and non-existing node")
414+
SECTION("Change (delete and set) existing and non-existing node")
415415
{
416416
{
417417
auto mid = std::make_shared<middle_pgsql_t>(&options);
@@ -430,7 +430,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
430430
mid->commit();
431431
}
432432
{
433-
// Check with a new mid
433+
// Check with a new mid.
434434
auto mid = std::make_shared<middle_pgsql_t>(&options);
435435
mid->start();
436436

@@ -460,7 +460,7 @@ TEMPLATE_TEST_CASE("middle add, delete and update node", "",
460460
mid->commit();
461461
}
462462
{
463-
// Check with a new mid
463+
// Check with a new mid.
464464
auto mid = std::make_shared<middle_pgsql_t>(&options);
465465
mid->start();
466466

@@ -488,16 +488,16 @@ static void check_way(std::shared_ptr<middle_pgsql_t> const &mid,
488488
REQUIRE(mid_q->way_get(orig_way.id(), outbuf));
489489
auto const &way = outbuf.get<osmium::Way>(0);
490490

491-
osmium::CRC<osmium::CRC_zlib> orig_way_crc;
492-
orig_way_crc.update(orig_way);
491+
osmium::CRC<osmium::CRC_zlib> orig_crc;
492+
orig_crc.update(orig_way);
493493

494-
osmium::CRC<osmium::CRC_zlib> test_way_crc;
495-
test_way_crc.update(way);
494+
osmium::CRC<osmium::CRC_zlib> test_crc;
495+
test_crc.update(way);
496496

497-
REQUIRE(orig_way_crc().checksum() == test_way_crc().checksum());
497+
REQUIRE(orig_crc().checksum() == test_crc().checksum());
498498
}
499499

500-
/// Return true if the way with the specified id is not in the mid
500+
/// Return true if the way with the specified id is not in the mid.
501501
static bool no_way(std::shared_ptr<middle_pgsql_t> const &mid, osmid_t id)
502502
{
503503
auto const mid_q = mid->get_query_instance();
@@ -514,7 +514,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
514514
testing::cleanup::file_t flatnode_cleaner{
515515
options.flat_node_file.get_value_or("")};
516516

517-
// create some ways we'll use for the tests
517+
// Create some ways we'll use for the tests.
518518
test_buffer_t buffer;
519519
auto const &way20 = buffer.add_way_and_get(
520520
20, {10, 11}, {{"highway", "residential"}, {"name", "High Street"}});
@@ -547,7 +547,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
547547
// From now on use append mode to not destroy the data we just added.
548548
options.append = true;
549549

550-
SECTION("Check that added ways are there and no others")
550+
SECTION("Added ways are there and no others")
551551
{
552552
auto mid = std::make_shared<middle_pgsql_t>(&options);
553553
mid->start();
@@ -579,7 +579,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
579579
mid->commit();
580580
}
581581
{
582-
// Check with a new mid
582+
// Check with a new mid.
583583
auto mid = std::make_shared<middle_pgsql_t>(&options);
584584
mid->start();
585585

@@ -592,7 +592,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
592592
}
593593
}
594594

595-
SECTION("Change (delete and set) existing way and non-existing way")
595+
SECTION("Change (delete and set) existing and non-existing way")
596596
{
597597
{
598598
auto mid = std::make_shared<middle_pgsql_t>(&options);
@@ -613,7 +613,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
613613
mid->commit();
614614
}
615615
{
616-
// Check with a new mid
616+
// Check with a new mid.
617617
auto mid = std::make_shared<middle_pgsql_t>(&options);
618618
mid->start();
619619

@@ -645,7 +645,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update way", "",
645645
mid->commit();
646646
}
647647
{
648-
// Check with a new mid
648+
// Check with a new mid.
649649
auto mid = std::make_shared<middle_pgsql_t>(&options);
650650
mid->start();
651651

@@ -671,7 +671,7 @@ TEMPLATE_TEST_CASE("middle: add way with attributes", "", options_slim_default,
671671
testing::cleanup::file_t flatnode_cleaner{
672672
options.flat_node_file.get_value_or("")};
673673

674-
// create some ways we'll use for the tests
674+
// Create some ways we'll use for the tests.
675675
test_buffer_t buffer;
676676
auto &way20 = buffer.add_way_and_get(
677677
20, {10, 11}, {{"highway", "residential"}, {"name", "High Street"}});
@@ -680,12 +680,12 @@ TEMPLATE_TEST_CASE("middle: add way with attributes", "", options_slim_default,
680680
way20.set_changeset(456);
681681
way20.set_uid(789);
682682

683-
// the same way but with default attributes
683+
// The same way but with default attributes.
684684
auto &way20_no_attr = buffer.add_way_and_get(
685685
20, {10, 11}, {{"highway", "residential"}, {"name", "High Street"}});
686686

687-
// the same way but with attributes in tags
688-
// the order of the tags is important here
687+
// The same way but with attributes in tags.
688+
// The order of the tags is important here!
689689
auto &way20_attr_tags =
690690
buffer.add_way_and_get(20, {10, 11},
691691
{{"highway", "residential"},
@@ -724,8 +724,8 @@ TEMPLATE_TEST_CASE("middle: add way with attributes", "", options_slim_default,
724724
}
725725

726726
/**
727-
* Check that the relation is in the mid with the right attributes and tags.
728-
* Does not check members.
727+
* Check that the relation is in the mid with the right attributes, members
728+
* and tags. Only checks the relation, does not recurse into members.
729729
*/
730730
static void check_relation(std::shared_ptr<middle_pgsql_t> const &mid,
731731
osmium::Relation const &orig_relation)
@@ -736,16 +736,16 @@ static void check_relation(std::shared_ptr<middle_pgsql_t> const &mid,
736736
REQUIRE(mid_q->relation_get(orig_relation.id(), outbuf));
737737
auto const &relation = outbuf.get<osmium::Relation>(0);
738738

739-
osmium::CRC<osmium::CRC_zlib> orig_relation_crc;
740-
orig_relation_crc.update(orig_relation);
739+
osmium::CRC<osmium::CRC_zlib> orig_crc;
740+
orig_crc.update(orig_relation);
741741

742-
osmium::CRC<osmium::CRC_zlib> test_relation_crc;
743-
test_relation_crc.update(relation);
742+
osmium::CRC<osmium::CRC_zlib> test_crc;
743+
test_crc.update(relation);
744744

745-
REQUIRE(orig_relation_crc().checksum() == test_relation_crc().checksum());
745+
REQUIRE(orig_crc().checksum() == test_crc().checksum());
746746
}
747747

748-
/// Return true if the relation with the specified id is not in the mid
748+
/// Return true if the relation with the specified id is not in the mid.
749749
static bool no_relation(std::shared_ptr<middle_pgsql_t> const &mid, osmid_t id)
750750
{
751751
auto const mid_q = mid->get_query_instance();
@@ -762,7 +762,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
762762
testing::cleanup::file_t flatnode_cleaner{
763763
options.flat_node_file.get_value_or("")};
764764

765-
// create some relations we'll use for the tests
765+
// Create some relations we'll use for the tests.
766766
test_buffer_t buffer;
767767
using otype = osmium::item_type;
768768
auto const &relation30 = buffer.add_relation_and_get(
@@ -799,7 +799,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
799799
// From now on use append mode to not destroy the data we just added.
800800
options.append = true;
801801

802-
SECTION("Check that added relations are there and no others")
802+
SECTION("Added relations are there and no others")
803803
{
804804
auto mid = std::make_shared<middle_pgsql_t>(&options);
805805
mid->start();
@@ -831,7 +831,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
831831
mid->commit();
832832
}
833833
{
834-
// Check with a new mid
834+
// Check with a new mid.
835835
auto mid = std::make_shared<middle_pgsql_t>(&options);
836836
mid->start();
837837

@@ -844,8 +844,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
844844
}
845845
}
846846

847-
SECTION(
848-
"Change (delete and set) existing relation and non-existing relation")
847+
SECTION("Change (delete and set) existing and non-existing relation")
849848
{
850849
{
851850
auto mid = std::make_shared<middle_pgsql_t>(&options);
@@ -866,7 +865,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
866865
mid->commit();
867866
}
868867
{
869-
// Check with a new mid
868+
// Check with a new mid.
870869
auto mid = std::make_shared<middle_pgsql_t>(&options);
871870
mid->start();
872871

@@ -898,7 +897,7 @@ TEMPLATE_TEST_CASE("middle: add, delete and update relation", "",
898897
mid->commit();
899898
}
900899
{
901-
// Check with a new mid
900+
// Check with a new mid.
902901
auto mid = std::make_shared<middle_pgsql_t>(&options);
903902
mid->start();
904903

@@ -925,7 +924,7 @@ TEMPLATE_TEST_CASE("middle: add relation with attributes", "",
925924
testing::cleanup::file_t flatnode_cleaner{
926925
options.flat_node_file.get_value_or("")};
927926

928-
// create some relations we'll use for the tests
927+
// Create some relations we'll use for the tests.
929928
test_buffer_t buffer;
930929
using otype = osmium::item_type;
931930
auto &relation30 = buffer.add_relation_and_get(
@@ -936,13 +935,13 @@ TEMPLATE_TEST_CASE("middle: add relation with attributes", "",
936935
relation30.set_changeset(456);
937936
relation30.set_uid(789);
938937

939-
// the same relation but with default attributes
938+
// The same relation but with default attributes.
940939
auto &relation30_no_attr = buffer.add_relation_and_get(
941940
30, {{otype::way, 10, "outer"}, {otype::way, 11, "inner"}},
942941
{{"type", "multipolygon"}, {"name", "Penguin Park"}});
943942

944-
// the same relation but with attributes in tags
945-
// the order of the tags is important here
943+
// The same relation but with attributes in tags.
944+
// The order of the tags is important here!
946945
auto &relation30_attr_tags = buffer.add_relation_and_get(
947946
30, {{otype::way, 10, "outer"}, {otype::way, 11, "inner"}},
948947
{{"type", "multipolygon"},

0 commit comments

Comments
 (0)