<commit_before>// Copyright 2017, <NAME>, <<EMAIL>>

#include "lel/lambda.hpp"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include <iostream>

using namespace ::testing;

class lambda_test : public ::testing::Test {
 protected:
  struct MockImpl {
    MOCK_CONST_METHOD0(slice0, int());
    MOCK_CONST_METHOD1(slice1, int(int));
  };

  template <class FuncT, FuncT Func>
  struct MockView {
    MockImpl& operator()() const {
      static MockImpl impl;
      return impl;
    }

    template <class Slice, class ... Args>
    auto slice(Slice, Args... args) const {
      return (operator()().*Func)(args...);
    }
  };
};

#define MOCK(ID, ARGS) \
  MockView<decltype(&MockImpl::slice##ID), &MockImpl::slice##ID> mock; \
  EXPECT_CALL(mock(), slice##ID(ARGS))

TEST_F(lambda_test, when_no_ids_and_view_doesnt_have_arguments_view_is_called) {
  MOCK(0, )
    .WillOnce(Return(5));

  LeL::Lambda<LeL::Context<LeL::Identity, decltype(mock)>,
              LeL::Template::Box<char>>
    lambda(mock);

  ASSERT_EQ(5, lambda());
}

TEST_F(lambda_test, when_no_ids_view_can_be_called_with_arguments) {
  MOCK(1, 1)
    .WillOnce(Return(7));

  LeL::Lambda<LeL::Context<LeL::Identity, decltype(mock)>,
              LeL::Template::Box<char, '0'>>
    lambda(mock);

  auto result = lambda(1);
  ASSERT_EQ(7, result);
}

#undef MOCK<commit_msg>Try to fix trafis<commit_after>// Copyright 2017, <NAME>, <<EMAIL>>

#include "lel/lambda.hpp"

#include "gmock/gmock.h"
#include "gtest/gtest.h"

#include <iostream>

using namespace ::testing;

class lambda_test : public ::testing::Test {
 protected:
  struct MockImpl {
    MOCK_CONST_METHOD0(slice0, int());
    MOCK_CONST_METHOD1(slice1, int(int));
  };

  template <class FuncT, FuncT Func>
  struct MockView {
    MockImpl& operator()() const {
      static MockImpl impl;
      return impl;
    }

    template <class Slice, class ... Args>
    auto slice(Slice, Args... args) const {
      return (operator()().*Func)(args...);
    }
  };
};

#define MOCK(ID, ARGS) \
  MockView<decltype(&MockImpl::slice##ID), &MockImpl::slice##ID> mock; \
  EXPECT_CALL(mock(), slice##ID(ARGS))

TEST_F(lambda_test, when_no_ids_and_view_doesnt_have_arguments_view_is_called) {
  MOCK(0, )
    .WillOnce(Return(5));

  LeL::Lambda<LeL::Context<LeL::Identity, decltype(mock)>,
              LeL::Template::Box<char>>
    lambda(mock);

  auto result = lambda();
  ASSERT_EQ(5, result);
}

TEST_F(lambda_test, when_no_ids_view_can_be_called_with_arguments) {
  MOCK(1, 1)
    .WillOnce(Return(7));

  LeL::Lambda<LeL::Context<LeL::Identity, decltype(mock)>,
              LeL::Template::Box<char, '0'>>
    lambda(mock);

  auto result = lambda(1);
  ASSERT_EQ(7, result);
}

#undef MOCK
{'fraction_non_alphanumeric': 0.16495601173020527, 'fraction_numerical': 0.012463343108504398, 'mean_word_length': 4.0724907063197024, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '6311180', 'n_tokens_mistral': 1027, 'n_tokens_neox': 1010, 'n_words': 183}