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

#include "DiceRoll/Operations/DiscardOperation.hpp"
#include "DiceRoll/Operations/GetNumberOperation.hpp"
#include "DiceRoll/Operations/RepeatOperation.h"
#include "DiceRoll/RollCompare/Comparators.hpp"
#include "DiceRoll/Operations/IOperation.hpp"

using namespace DiceRoll;

class MultiMockOperation : public IOperation {
  std::unique_ptr<RollResult> execute() {
    return std::make_unique<RollResult>();
  }
 public:
  MultiMockOperation() {}

  std::unique_ptr<RollResult> evaluate() {
    auto result = std::make_unique<RollResult>();
    result->setFullResult("(3 2 4 1)");
    result->setShortResult(std::vector<int>({3, 2, 4, 1}));
    return result;
  }
};

TEST(DiscardOperationTest, WorkWithSingularValueOperation)
{
  DiceRoll::PrioritizeHigher comp;
  GetNumberOperation numOp(5);

  // Will fall out of scope;
  ASSERT_NO_THROW(DiscardOperation disOp(&numOp, 1, &comp));

  DiscardOperation disOp(&numOp, 1, &comp);
  auto result = disOp.evaluate();

  EXPECT_EQ(result->getShortResult(), std::vector<int>({5}));
  EXPECT_EQ(result->getFullResult(), "5");
}

TEST(DiscardOperationTest, WorkWithMultipleValue)
{
  DiceRoll::PrioritizeHigher comp;
  MultiMockOperation mulOp;

  // Will fall out of scope;
  ASSERT_NO_THROW(DiscardOperation disOp(&mulOp, 1, &comp));

  DiscardOperation disOp(&mulOp, 1, &comp);
  auto result = disOp.evaluate();

  EXPECT_EQ(result->getShortResult(), std::vector<int>({4}));
  EXPECT_EQ(result->getFullResult(), "(dis[1, >]: 4 :(3 2 4 1))");
}<commit_msg>Test to check if leaving more than result length in DiscardOperation<commit_after>#include "gtest/gtest.h"

#include "DiceRoll/Operations/DiscardOperation.hpp"
#include "DiceRoll/Operations/GetNumberOperation.hpp"
#include "DiceRoll/Operations/RepeatOperation.h"
#include "DiceRoll/RollCompare/Comparators.hpp"
#include "DiceRoll/Operations/IOperation.hpp"

using namespace DiceRoll;

class MultiMockOperation : public IOperation {
  std::unique_ptr<RollResult> execute() {
    return std::make_unique<RollResult>();
  }
 public:
  MultiMockOperation() {}

  std::unique_ptr<RollResult> evaluate() {
    auto result = std::make_unique<RollResult>();
    result->setFullResult("(3 2 4 1)");
    result->setShortResult(std::vector<int>({3, 2, 4, 1}));
    return result;
  }
};

TEST(DiscardOperationTest, WorkWithSingularValueOperation)
{
  DiceRoll::PrioritizeHigher comp;
  GetNumberOperation numOp(5);

  // Will fall out of scope;
  ASSERT_NO_THROW(DiscardOperation disOp(&numOp, 1, &comp));

  DiscardOperation disOp(&numOp, 1, &comp);
  auto result = disOp.evaluate();

  EXPECT_EQ(result->getShortResult(), std::vector<int>({5}));
  EXPECT_EQ(result->getFullResult(), "5");
}

TEST(DiscardOperationTest, WorkWithMultipleValue)
{
  DiceRoll::PrioritizeHigher comp;
  MultiMockOperation mulOp;

  // Will fall out of scope;
  ASSERT_NO_THROW(DiscardOperation disOp(&mulOp, 1, &comp));

  DiscardOperation disOp(&mulOp, 1, &comp);
  auto result = disOp.evaluate();

  EXPECT_EQ(result->getShortResult(), std::vector<int>({4}));
  EXPECT_EQ(result->getFullResult(), "(dis[1, >]: 4 :(3 2 4 1))");
}

TEST(DiscardOperationTest, DontChangeOnLeaveMoreThanInResult)
{
  DiceRoll::PrioritizeHigher comp;
  MultiMockOperation mulOp;  // has 4-value result

  DiscardOperation disOp(&mulOp, 10, &comp);
  auto result = disOp.evaluate();

  EXPECT_EQ(result->getShortResultSize(), 4);
  EXPECT_EQ(result->getFullResult(), "(3 2 4 1)");
}
{'fraction_non_alphanumeric': 0.14795624640184227, 'fraction_numerical': 0.014968336211859529, 'mean_word_length': 6.006048387096774, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, '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': '3284221', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1178, 'n_words': 227}