<commit_before>/**
* @version		GrPPI v0.2
* @copyright		Copyright (C) 2017 Universidad Carlos III de Madrid. All rights reserved.
* @license		GNU/GPL, see LICENSE.txt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You have received a copy of the GNU General Public License in LICENSE.txt
* also available in <http://www.gnu.org/licenses/gpl.html>.
*
* See COPYRIGHT.txt for copyright notices and details.
*/
#include <atomic>

#include <gtest/gtest.h>

#include "reduce.h"
#include "common/polymorphic_execution.h"

#include "supported_executions.h"

using namespace std;
using namespace grppi;

template <typename T>
class reduce_test : public ::testing::Test {
public:
  T execution_;
  polymorphic_execution poly_execution_ = 
    make_polymorphic_execution<T>();

  // Variables
  int out;

  // Vectors
  vector<int> v{};
  vector<int> v2{};
  vector<int> v3{};
  vector<int> w{};
  vector<int> expected{};

  void setup_empty() {
    out = 0;
  }

  void check_empty() {
    EXPECT_EQ(0, this->out);
  }

  void setup_single() {
    out = 0;
    v = vector<int>{1};
  }

  void check_single() {
    EXPECT_EQ(1, this->out);
  }

  void setup_multiple() {
    out = 0;
    v = vector<int>{1,2,3,4,5};
  }

  void check_multiple() {
    EXPECT_EQ(15, this->out); 
  }



};

// Test for execution policies defined in supported_executions.h
TYPED_TEST_CASE(reduce_test, executions);

TYPED_TEST(reduce_test, static_empty)
{
  this->setup_empty();
  grppi::reduce(this->execution_, begin(this->v), end(this->v), this->out,
   std::plus<int>()
  );
  this->check_empty();
}

TYPED_TEST(reduce_test, static_single)
{
  this->setup_single();
  grppi::reduce(this->execution_, begin(this->v), end(this->v), this->out,
   std::plus<int>()
  );<commit_msg>Removed unnecessary variables<commit_after>/**
* @version		GrPPI v0.2
* @copyright		Copyright (C) 2017 Universidad Carlos III de Madrid. All rights reserved.
* @license		GNU/GPL, see LICENSE.txt
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You have received a copy of the GNU General Public License in LICENSE.txt
* also available in <http://www.gnu.org/licenses/gpl.html>.
*
* See COPYRIGHT.txt for copyright notices and details.
*/
#include <atomic>

#include <gtest/gtest.h>

#include "reduce.h"
#include "common/polymorphic_execution.h"

#include "supported_executions.h"

using namespace std;
using namespace grppi;

template <typename T>
class reduce_test : public ::testing::Test {
public:
  T execution_;
  polymorphic_execution poly_execution_ = 
    make_polymorphic_execution<T>();

  // Variables
  int out;

  // Vectors
  vector<int> v{};

  void setup_empty() {
    out = 0;
  }

  void check_empty() {
    EXPECT_EQ(0, this->out);
  }

  void setup_single() {
    out = 0;
    v = vector<int>{1};
  }

  void check_single() {
    EXPECT_EQ(1, this->out);
  }

  void setup_multiple() {
    out = 0;
    v = vector<int>{1,2,3,4,5};
  }

  void check_multiple() {
    EXPECT_EQ(15, this->out); 
  }

};

// Test for execution policies defined in supported_executions.h
TYPED_TEST_CASE(reduce_test, executions);

TYPED_TEST(reduce_test, static_empty)
{
  this->setup_empty();
  grppi::reduce(this->execution_, begin(this->v), end(this->v), this->out,
   std::plus<int>()
  );
  this->check_empty();
}

TYPED_TEST(reduce_test, static_single)
{
  this->setup_single();
  grppi::reduce(this->execution_, begin(this->v), end(this->v), this->out,
   std::plus<int>()
  );
{'fraction_non_alphanumeric': 0.12514430847379357, 'fraction_numerical': 0.009697529438928654, 'mean_word_length': 4.008092485549133, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 55, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3587030', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1417, 'n_words': 434}