test/src/storage/trie/supergenius_trie/supergenius_trie_test.cpp
TEST_F(TrieTest, ClearPrefix) {
  std::vector<std::pair<Buffer, Buffer>> data = {{"bark"_buf, "123"_buf},
                                                 {"barnacle"_buf, "456"_buf},
                                                 {"bat"_buf, "789"_buf},
                                                 {"batch"_buf, "0-="_buf}};
  for (auto &entry : data) {
    EXPECT_OUTCOME_TRUE_1(trie->put(entry.first, entry.second));
  }
  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("bar"_buf));
  ASSERT_TRUE(trie->contains("bat"_buf));
  ASSERT_TRUE(trie->contains("batch"_buf));
  ASSERT_FALSE(trie->contains("bark"_buf));
  ASSERT_FALSE(trie->contains("barnacle"_buf));

  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("batc"_buf));
  ASSERT_TRUE(trie->contains("bat"_buf));
  ASSERT_FALSE(trie->contains("batch"_buf));

  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("b"_buf));
  ASSERT_FALSE(trie->contains("bat"_buf));
  ASSERT_TRUE(trie->empty());
}
/**
 * @given a trie
 * @when deleting entries in it that start with a prefix
 * @then there is no entries with such prefix in the trie
 */
@given a trie
@when deleting entries in it that start with a prefix
@then there is no entries with such prefix in the trie
@given a trie @when deleting entries in it that start with a prefix @then there is no entries with such prefix in the trie
TEST_F(TrieTest, ClearPrefix) {
  std::vector<std::pair<Buffer, Buffer>> data = {{"bark"_buf, "123"_buf},
                                                 {"barnacle"_buf, "456"_buf},
                                                 {"bat"_buf, "789"_buf},
                                                 {"batch"_buf, "0-="_buf}};
  for (auto &entry : data) {
    EXPECT_OUTCOME_TRUE_1(trie->put(entry.first, entry.second));
  }
  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("bar"_buf));
  ASSERT_TRUE(trie->contains("bat"_buf));
  ASSERT_TRUE(trie->contains("batch"_buf));
  ASSERT_FALSE(trie->contains("bark"_buf));
  ASSERT_FALSE(trie->contains("barnacle"_buf));
  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("batc"_buf));
  ASSERT_TRUE(trie->contains("bat"_buf));
  ASSERT_FALSE(trie->contains("batch"_buf));
  EXPECT_OUTCOME_TRUE_1(trie->clearPrefix("b"_buf));
  ASSERT_FALSE(trie->contains("bat"_buf));
  ASSERT_TRUE(trie->empty());
}
TEST_F ( TrieTest , ClearPrefix ) { std :: vector < std :: pair < Buffer , Buffer > > data = { { " " _buf , " " _buf } , { " " _buf , " " _buf } , { " " _buf , " " _buf } , { " " _buf , " " _buf } } ; for ( auto & entry : data ) { EXPECT_OUTCOME_TRUE_1 ( trie -> put ( entry . first , entry . second ) ) ; } EXPECT_OUTCOME_TRUE_1 ( trie -> clearPrefix ( " " _buf ) ) ; ASSERT_TRUE ( trie -> contains ( " " _buf ) ) ; ASSERT_TRUE ( trie -> contains ( " " _buf ) ) ; ASSERT_FALSE ( trie -> contains ( " " _buf ) ) ; ASSERT_FALSE ( trie -> contains ( " " _buf ) ) ; EXPECT_OUTCOME_TRUE_1 ( trie -> clearPrefix ( " " _buf ) ) ; ASSERT_TRUE ( trie -> contains ( " " _buf ) ) ; ASSERT_FALSE ( trie -> contains ( " " _buf ) ) ; EXPECT_OUTCOME_TRUE_1 ( trie -> clearPrefix ( " " _buf ) ) ; ASSERT_FALSE ( trie -> contains ( " " _buf ) ) ; ASSERT_TRUE ( trie -> empty ( ) ) ; }
@given a trie
 @when deleting entries in it that start with a prefix
 @then there is no entries with such prefix in the trie
@given a trie @when deleting entries in it that start with a prefix @then there is no entries with such prefix in the trie