<commit_before>#include "gtest/gtest.h"
#include <rapidcheck/gtest.h>

#include <string>

#include SPECIFIC_HEADER

// Running tests

TEST(TEST_NAME, EmptyPattern)
{
  ASSERT_EQ(0, find_substr("AZERTY", ""));
}
TEST(TEST_NAME, MatchItself)
{
  ASSERT_EQ(0, find_substr("AZERTY", "AZERTY"));
}
TEST(TEST_NAME, MatchAtTheBeginning)
{
  ASSERT_EQ(0, find_substr("AZERTY", "AZ"));
}
TEST(TEST_NAME, MatchInside)
{
  ASSERT_EQ(2, find_substr("AZERTY", "ERT"));
}
TEST(TEST_NAME, MatchAtTheEnd)
{
  ASSERT_EQ(3, find_substr("AZERTY", "RTY"));
}
TEST(TEST_NAME, CyclicPattern)
{
  ASSERT_EQ(4, find_substr("ABABABABBABABAB", "ABABB"));
}
TEST(TEST_NAME, FirstMatchIfMultiple)
{
  ASSERT_EQ(1, find_substr("ABABABABBABABAB", "BA"));
}
TEST(TEST_NAME, NoMatch)
{
  ASSERT_EQ(std::string::npos, find_substr("ABABABABBABABAB", "BAA"));
}

RC_GTEST_PROP(TEST_NAME, FindMatch, ())
{
  auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
  std::string s1 = *gen;
  std::string s2 = *gen;
  std::string s3 = *gen;
  RC_ASSERT(find_substr(s1+s2+s3, s2) != std::string::npos);
}
RC_GTEST_PROP(TEST_NAME, FindFirstMatch, ())
{
  auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
  std::string s1 = *gen;
  std::string s2 = *gen;
  std::string s3 = *gen;
  RC_PRE(! s2.empty());
  RC_ASSERT(find_substr(s1+s2+s3, s2) <= s1.size());
}

int main(int argc, char **argv)
{
  ::testing::InitGoogleTest(&argc, argv);
  int ret { RUN_ALL_TESTS() };
  return ret;
}
<commit_msg>[contiguous-data/find-substr] Add some failing unit-tests<commit_after>#include "gtest/gtest.h"
#include <rapidcheck/gtest.h>

#include <string>

#include SPECIFIC_HEADER

// Running tests

TEST(TEST_NAME, EmptyPattern)
{
  ASSERT_EQ(0, find_substr("AZERTY", ""));
}
TEST(TEST_NAME, MatchItself)
{
  ASSERT_EQ(0, find_substr("AZERTY", "AZERTY"));
}
TEST(TEST_NAME, MatchAtTheBeginning)
{
  ASSERT_EQ(0, find_substr("AZERTY", "AZ"));
}
TEST(TEST_NAME, MatchInside)
{
  ASSERT_EQ(2, find_substr("AZERTY", "ERT"));
}
TEST(TEST_NAME, MatchAtTheEnd)
{
  ASSERT_EQ(3, find_substr("AZERTY", "RTY"));
}
TEST(TEST_NAME, RepeatedFirstChar)
{
  ASSERT_EQ(1, find_substr("AAB", "AB"));
}
TEST(TEST_NAME, RepeatedFirstChars)
{
  ASSERT_EQ(2, find_substr("FEFEFA", "FEFA"));
}
TEST(TEST_NAME, CyclicPattern)
{
  ASSERT_EQ(4, find_substr("ABABABABBABABAB", "ABABB"));
}
TEST(TEST_NAME, FirstMatchIfMultiple)
{
  ASSERT_EQ(1, find_substr("ABABABABBABABAB", "BA"));
}
TEST(TEST_NAME, NoMatch)
{
  ASSERT_EQ(std::string::npos, find_substr("ABABABABBABABAB", "BAA"));
}

RC_GTEST_PROP(TEST_NAME, FindMatch, ())
{
  auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
  std::string s1 = *gen;
  std::string s2 = *gen;
  std::string s3 = *gen;
  RC_ASSERT(find_substr(s1+s2+s3, s2) != std::string::npos);
}
RC_GTEST_PROP(TEST_NAME, FindFirstMatch, ())
{
  auto gen = rc::gen::container<std::string>(rc::gen::inRange('A', (char)('Z' +1)));
  std::string s1 = *gen;
  std::string s2 = *gen;
  std::string s3 = *gen;
  RC_PRE(! s2.empty());
  RC_ASSERT(find_substr(s1+s2+s3, s2) <= s1.size());
}

int main(int argc, char **argv)
{
  ::testing::InitGoogleTest(&argc, argv);
  int ret { RUN_ALL_TESTS() };
  return ret;
}

{'fraction_non_alphanumeric': 0.202344231955583, 'fraction_numerical': 0.016039481801357187, 'mean_word_length': 6.703087885985748, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5317334', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1365, 'n_words': 216}