@@ -493,7 +493,7 @@ TEST(MergeCompactor, ResultSetDropKeyRange)
493493class ResultSetConcatTest : public ::testing::Test
494494{
495495 public:
496- void generate_edits (usize num_edits, bool needs_sort = true )
496+ void generate_edits (usize num_edits)
497497 {
498498 std::unordered_set<KeyView> keys_set;
499499
@@ -509,13 +509,7 @@ class ResultSetConcatTest : public ::testing::Test
509509 ValueView::from_str (this ->store_ .store (std::string (100 , ' a' ))));
510510 }
511511
512- if (needs_sort) {
513- std::sort (this ->all_edits_ .begin (), this ->all_edits_ .end (), KeyOrder{});
514- } else {
515- if (std::is_sorted (this ->all_edits_ .begin (), this ->all_edits_ .end (), KeyOrder{})) {
516- std::swap (this ->all_edits_ .front (), this ->all_edits_ .back ());
517- }
518- }
512+ std::sort (this ->all_edits_ .begin (), this ->all_edits_ .end (), KeyOrder{});
519513 }
520514
521515 template <bool kDecayToItems >
@@ -580,7 +574,7 @@ TEST_F(ResultSetConcatTest, Concat)
580574 //
581575 this ->verify_result_set (concatenated_result_set, this ->all_edits_ );
582576
583- // Now, repeat the process qith unequal sized inputs
577+ // Now, repeat the process with unequal sized inputs.
584578 //
585579 first.assign (this ->all_edits_ .begin (), this ->all_edits_ .begin () + (n / 4 ));
586580 second.assign (this ->all_edits_ .begin () + (n / 4 ), this ->all_edits_ .end ());
@@ -596,6 +590,14 @@ TEST_F(ResultSetConcatTest, Concat)
596590
597591 concatenated_result_set = this ->concat (std::move (first), std::move (second), DecayToItem<false >{});
598592
593+ this ->verify_result_set (concatenated_result_set,
594+ {this ->all_edits_ .begin (), this ->all_edits_ .begin () + (n / 4 )});
595+
596+ first.assign (this ->all_edits_ .begin (), this ->all_edits_ .begin () + (n / 4 ));
597+ second = {};
598+
599+ concatenated_result_set = this ->concat (std::move (first), std::move (second), DecayToItem<false >{});
600+
599601 this ->verify_result_set (concatenated_result_set,
600602 {this ->all_edits_ .begin (), this ->all_edits_ .begin () + (n / 4 )});
601603
@@ -648,11 +650,15 @@ TEST_F(ResultSetConcatTest, FragmentedConcat)
648650TEST_F (ResultSetConcatTest, ConcatDeath)
649651{
650652 usize n = 200 ;
651- this ->generate_edits (n, /* needs_sort */ false );
653+ this ->generate_edits (n);
652654
653655 std::vector<EditView> first{this ->all_edits_ .begin (), this ->all_edits_ .begin () + (n / 2 )};
654656 std::vector<EditView> second{this ->all_edits_ .begin () + (n / 2 ), this ->all_edits_ .end ()};
655657
658+ // Undo the sorting.
659+ //
660+ std::swap (first.back (), second.front ());
661+
656662 // We should panic since first and second have overlapping key ranges.
657663 //
658664 EXPECT_DEATH (this ->concat (std::move (first), std::move (second), DecayToItem<false >{}),
0 commit comments