<commit_before>/**
 *  @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may find a copy of the License in the LICENCE file.
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  @file JPetCommonToolsTest.cpp
 */

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE JPetCommonToolsTest
#include "JPetCommonTools/JPetCommonTools.h"

#include <boost/test/unit_test.hpp>
#include <iostream>
#include <map>

BOOST_AUTO_TEST_SUITE(CommonToolsTestSuite)

BOOST_AUTO_TEST_CASE(ItoaTest)
{
  int testNumber = 64;
  std::string intAsASting = JPetCommonTools::Itoa(testNumber);
  BOOST_REQUIRE_EQUAL(intAsASting, "64");
}

BOOST_AUTO_TEST_CASE(intToStringTest)
{
  int testNumber = 64;
  std::string intAsASting = JPetCommonTools::intToString(testNumber);
  BOOST_REQUIRE_EQUAL(intAsASting, "64");
}

BOOST_AUTO_TEST_CASE(doubleToStringTest)
{
  double testNumber = 256.3264;
  std::string doubleAsASting = JPetCommonTools::doubleToString(testNumber);
  BOOST_REQUIRE_EQUAL(doubleAsASting, "256.326");
}

BOOST_AUTO_TEST_CASE(stringToIntTest)
{
  std::string testString = "1024";
  int stringAsAInt = JPetCommonTools::stringToInt(testString);
  BOOST_REQUIRE_EQUAL(stringAsAInt, 1024);
}

BOOST_AUTO_TEST_CASE(toBoolTest)
{
  std::string testString = "0";
  bool stringAsABool = JPetCommonTools::to_bool(testString);
  BOOST_REQUIRE(!stringAsABool);
}

BOOST_AUTO_TEST_CASE(ifFileExistingTest)
{
  std::string fileTest = "run_tests.pl";
  bool ifFileExisting = JPetCommonTools::ifFileExisting(fileTest);
  BOOST_REQUIRE(ifFileExisting);
}

BOOST_AUTO_TEST_CASE(mapAreEqualTest)
{
  std::map<int, int> mapTestLeft, mapTestRight;
  bool areMapsEqual = JPetCommonTools::mapComparator(mapTestLeft, mapTestRight);
  BOOST_REQUIRE(areMapsEqual);
}

BOOST_AUTO_TEST_CASE(mapAreNotEqualTest)
{
  std::map<char, int> first;
  first['a'] = 10;
  first['b'] = 30;
  first['c'] = 50;
  first['d'] = 70;
  std::map<char, int> second;

  bool areMapsEqual = JPetCommonTools::mapComparator(first, second);
  BOOST_REQUIRE(!areMapsEqual);
}
<commit_msg>Fix missing run_tests.pl<commit_after>/**
 *  @copyright Copyright 2018 The J-PET Framework Authors. All rights reserved.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may find a copy of the License in the LICENCE file.
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 *  @file JPetCommonToolsTest.cpp
 */

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE JPetCommonToolsTest
#include "JPetCommonTools/JPetCommonTools.h"

#include <boost/test/unit_test.hpp>
#include <iostream>
#include <map>

BOOST_AUTO_TEST_SUITE(CommonToolsTestSuite)

BOOST_AUTO_TEST_CASE(ItoaTest)
{
  int testNumber = 64;
  std::string intAsASting = JPetCommonTools::Itoa(testNumber);
  BOOST_REQUIRE_EQUAL(intAsASting, "64");
}

BOOST_AUTO_TEST_CASE(intToStringTest)
{
  int testNumber = 64;
  std::string intAsASting = JPetCommonTools::intToString(testNumber);
  BOOST_REQUIRE_EQUAL(intAsASting, "64");
}

BOOST_AUTO_TEST_CASE(doubleToStringTest)
{
  double testNumber = 256.3264;
  std::string doubleAsASting = JPetCommonTools::doubleToString(testNumber);
  BOOST_REQUIRE_EQUAL(doubleAsASting, "256.326");
}

BOOST_AUTO_TEST_CASE(stringToIntTest)
{
  std::string testString = "1024";
  int stringAsAInt = JPetCommonTools::stringToInt(testString);
  BOOST_REQUIRE_EQUAL(stringAsAInt, 1024);
}

BOOST_AUTO_TEST_CASE(toBoolTest)
{
  std::string testString = "0";
  bool stringAsABool = JPetCommonTools::to_bool(testString);
  BOOST_REQUIRE(!stringAsABool);
}

BOOST_AUTO_TEST_CASE(ifFileExistingTest)
{
  std::string fileTest = "JPetCommonToolsTest.x";
  bool ifFileExisting = JPetCommonTools::ifFileExisting(fileTest);
  BOOST_REQUIRE(ifFileExisting);
}

BOOST_AUTO_TEST_CASE(mapAreEqualTest)
{
  std::map<int, int> mapTestLeft, mapTestRight;
  bool areMapsEqual = JPetCommonTools::mapComparator(mapTestLeft, mapTestRight);
  BOOST_REQUIRE(areMapsEqual);
}

BOOST_AUTO_TEST_CASE(mapAreNotEqualTest)
{
  std::map<char, int> first;
  first['a'] = 10;
  first['b'] = 30;
  first['c'] = 50;
  first['d'] = 70;
  std::map<char, int> second;

  bool areMapsEqual = JPetCommonTools::mapComparator(first, second);
  BOOST_REQUIRE(!areMapsEqual);
}

{'fraction_non_alphanumeric': 0.103330658105939, 'fraction_numerical': 0.01765650080256822, 'mean_word_length': 6.121428571428571, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '7210', 'n_tokens_mistral': 1797, 'n_tokens_neox': 1726, 'n_words': 380}