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

int main(int argc, char** argv) {
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}<commit_msg>unittests: leak detection code.<commit_after>#include <gtest/gtest.h>

#include <iostream>

using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestCase;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
using ::testing::UnitTest;
#if WIN32
#if DEBUG
#define ENABLE_MEMORY_LEAK_DETECTION
#endif
#endif

#ifdef ENABLE_MEMORY_LEAK_DETECTION
#define _CRTDBG_MAP_ALLOC
#include <crtdbg.h>
#include <stdlib.h>

class LeakChecker : public EmptyTestEventListener {
private:
  virtual void OnTestStart(const TestInfo & /* test_info */) { _CrtMemCheckpoint(&s1); }

  virtual void OnTestEnd(const TestInfo & /* test_info */) {
    _CrtMemCheckpoint(&s2);
    if (_CrtMemDifference(&s3, &s1, &s2)) {
      _CrtMemDumpAllObjectsSince(&s3);
    }
  }

  _CrtMemState s1 = {0}, s2 = {0}, s3 = {0};
};
#endif
int main(int argc, char **argv) {
  ::testing::InitGoogleTest(&argc, argv);
#ifdef ENABLE_MEMORY_LEAK_DETECTION
  _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
  _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDOUT);
  _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
  _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDOUT);
  _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
  _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
  TestEventListeners &listeners = UnitTest::GetInstance()->listeners();
  listeners.Append(new LeakChecker);
#endif
  return RUN_ALL_TESTS();
}
{'fraction_non_alphanumeric': 0.131047152480098, 'fraction_numerical': 0.008573178199632579, 'mean_word_length': 7.129353233830845, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, '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': '3993389', 'n_tokens_mistral': 617, 'n_tokens_neox': 602, 'n_words': 109}