<commit_before>/*********************************************************************************
* Copyright (c) 2013 <NAME> <<EMAIL>>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*    <NAME> - initial code and implementation
********************************************************************************/

#include <cstdlib>  // EXIT_SUCCESS
#include <ctime>    // time functions
#include <cstring>  // std::strlen, std::strncmp
#include <string>   // std::string
#include <fstream>  // std::fstream
#include <memory>   // std::auto_ptr
#include <ctime>    // strftime

#include <cpptest.h> // CppTest Framework

#include "piecewise_point_creator_test_suite.hpp"         // piecewise_point_creator_test_suite
#include "piecewise_polygon_creator_test_suite.hpp"       // piecewise_polygon_creator_test_suite
#include "piecewise_circle_creator_test_suite.hpp"        // piecewise_circle_creator_test_suite
#include "piecewise_cubic_spline_creator_test_suite.hpp"  // piecewise_cubic_spline_creator_test_suite
#include "piecewise_hyperellipse_creator_test_suite.hpp"  // piecewise_hyperellipse_creator_test_suite

enum TestType {testTypeText, testTypeCompiler, testTypeHTML};

int main(int argc, char *argv[])
{
  Test::Output *pout;
  TestType tt(testTypeCompiler);
  int rtn(EXIT_SUCCESS);

  // if user passed command line argument then parse it
  if (argc==1)
  {
    tt=testTypeCompiler;
  }
  else if (argc==2)
  {
    size_t lenargv(strlen(argv[1]));

    // using short codes
    if (lenargv==2)
    {
      if (argv[1][0]=='-')
      {
        switch(argv[1][1])
        {
          case('t'):
            tt=testTypeText;
            break;
          case('c'):
            tt=testTypeCompiler;
            break;
          case('h'):
            tt=testTypeHTML;
            break;
          default:
            std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
            rtn=EXIT_FAILURE;
            break;
        }
      }
      else
      {
        std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
        rtn=EXIT_FAILURE;
      }
    }
    else
    {
      if (lenargv==6)
      {
        if (std::strncmp(argv[1], "--text", lenargv)==0)
          tt=testTypeText;
        else if (std::strncmp(argv[1], "--html", lenargv)==0)
          tt=testTypeHTML;
        else if (std::strncmp(argv[1], "--help", lenargv)==0)
          rtn=EXIT_FAILURE;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
      else if (lenargv==10)
      {
        if (std::strncmp(argv[1], "--compiler", lenargv)==0)
          tt=testTypeCompiler;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
    }
  }
  else
  {
    std::cerr << "Can only pass one argument." << std::endl;
    rtn=EXIT_FAILURE;
  }
  if (rtn==EXIT_FAILURE)
  {
    std::cerr << "  Usage: " << argv[0] << " [--text|-t|--compiler|-c|--html|-h]" << std::endl;
    return rtn;
  }

  // allocate the correct output type
  switch (tt)
  {
    case(testTypeText):
    {
      Test::TextOutput *po = new Test::TextOutput(Test::TextOutput::Verbose);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeCompiler):
    {
      Test::CompilerOutput *po = new Test::CompilerOutput(Test::CompilerOutput::GCC);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeHTML):
    {
      Test::HtmlOutput *po = new Test::HtmlOutput;
      pout = static_cast<Test::Output *>(po);
      break;
    }
    default:
    {
      rtn=EXIT_FAILURE;
      break;
    }
  }

  if (rtn == EXIT_SUCCESS)
  {
    // get the current time information
    time_t rawtime;
    struct tm * timeinfo;
    std::string datetime;
    time (&rawtime);
    timeinfo = localtime(&rawtime);
    datetime = asctime(timeinfo);

    // add the test suites to the test runner
    // NOTE: This is where changes should be needed
    //
    Test::Suite ts;
    std::string ostr_filename("piecewise_curve_test_results.html");

    // add the cppack test suites
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<qd_real>()));
#endif

    //
    // NOTE: End of section that should be changed

    // run the test
    rtn = (ts.run(*pout)) ? EXIT_SUCCESS : EXIT_FAILURE;

    // generate the html data if requested
    if (tt==testTypeHTML)
    {
      std::ofstream ostr(ostr_filename.c_str());
      Test::HtmlOutput *phtmlout=dynamic_cast<Test::HtmlOutput *>(pout);

      phtmlout->generate(ostr, true, datetime);

      ostr.close();
    }

    delete pout;
  }

  return rtn;
}
<commit_msg>QD library gives error about negative argument to log function.<commit_after>/*********************************************************************************
* Copyright (c) 2013 <NAME> <<EMAIL>>
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*    <NAME> - initial code and implementation
********************************************************************************/

#include <cstdlib>  // EXIT_SUCCESS
#include <ctime>    // time functions
#include <cstring>  // std::strlen, std::strncmp
#include <string>   // std::string
#include <fstream>  // std::fstream
#include <memory>   // std::auto_ptr
#include <ctime>    // strftime

#include <cpptest.h> // CppTest Framework

#include "piecewise_point_creator_test_suite.hpp"         // piecewise_point_creator_test_suite
#include "piecewise_polygon_creator_test_suite.hpp"       // piecewise_polygon_creator_test_suite
#include "piecewise_circle_creator_test_suite.hpp"        // piecewise_circle_creator_test_suite
#include "piecewise_cubic_spline_creator_test_suite.hpp"  // piecewise_cubic_spline_creator_test_suite
#include "piecewise_hyperellipse_creator_test_suite.hpp"  // piecewise_hyperellipse_creator_test_suite

enum TestType {testTypeText, testTypeCompiler, testTypeHTML};

int main(int argc, char *argv[])
{
  Test::Output *pout;
  TestType tt(testTypeCompiler);
  int rtn(EXIT_SUCCESS);

  // if user passed command line argument then parse it
  if (argc==1)
  {
    tt=testTypeCompiler;
  }
  else if (argc==2)
  {
    size_t lenargv(strlen(argv[1]));

    // using short codes
    if (lenargv==2)
    {
      if (argv[1][0]=='-')
      {
        switch(argv[1][1])
        {
          case('t'):
            tt=testTypeText;
            break;
          case('c'):
            tt=testTypeCompiler;
            break;
          case('h'):
            tt=testTypeHTML;
            break;
          default:
            std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
            rtn=EXIT_FAILURE;
            break;
        }
      }
      else
      {
        std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
        rtn=EXIT_FAILURE;
      }
    }
    else
    {
      if (lenargv==6)
      {
        if (std::strncmp(argv[1], "--text", lenargv)==0)
          tt=testTypeText;
        else if (std::strncmp(argv[1], "--html", lenargv)==0)
          tt=testTypeHTML;
        else if (std::strncmp(argv[1], "--help", lenargv)==0)
          rtn=EXIT_FAILURE;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
      else if (lenargv==10)
      {
        if (std::strncmp(argv[1], "--compiler", lenargv)==0)
          tt=testTypeCompiler;
        else
        {
          std::cerr << "Unrecognized parameter: " << argv[1] << std::endl;
          rtn=EXIT_FAILURE;
        }
      }
    }
  }
  else
  {
    std::cerr << "Can only pass one argument." << std::endl;
    rtn=EXIT_FAILURE;
  }
  if (rtn==EXIT_FAILURE)
  {
    std::cerr << "  Usage: " << argv[0] << " [--text|-t|--compiler|-c|--html|-h]" << std::endl;
    return rtn;
  }

  // allocate the correct output type
  switch (tt)
  {
    case(testTypeText):
    {
      Test::TextOutput *po = new Test::TextOutput(Test::TextOutput::Verbose);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeCompiler):
    {
      Test::CompilerOutput *po = new Test::CompilerOutput(Test::CompilerOutput::GCC);
      pout = static_cast<Test::Output *>(po);
      break;
    }
    case(testTypeHTML):
    {
      Test::HtmlOutput *po = new Test::HtmlOutput;
      pout = static_cast<Test::Output *>(po);
      break;
    }
    default:
    {
      rtn=EXIT_FAILURE;
      break;
    }
  }

  if (rtn == EXIT_SUCCESS)
  {
    // get the current time information
    time_t rawtime;
    struct tm * timeinfo;
    std::string datetime;
    time (&rawtime);
    timeinfo = localtime(&rawtime);
    datetime = asctime(timeinfo);

    // add the test suites to the test runner
    // NOTE: This is where changes should be needed
    //
    Test::Suite ts;
    std::string ostr_filename("piecewise_curve_test_results.html");

    // add the cppack test suites
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_point_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_polygon_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_circle_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<long double>()));
#ifdef ELI_USING_QD
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<dd_real>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_cubic_spline_creator_test_suite<qd_real>()));
#endif
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<float>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<double>()));
    ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<long double>()));
// #ifdef ELI_USING_QD
//     ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<dd_real>()));
//     ts.add(std::auto_ptr<Test::Suite>(new piecewise_hyperellipse_creator_test_suite<qd_real>()));
// #endif

    //
    // NOTE: End of section that should be changed

    // run the test
    rtn = (ts.run(*pout)) ? EXIT_SUCCESS : EXIT_FAILURE;

    // generate the html data if requested
    if (tt==testTypeHTML)
    {
      std::ofstream ostr(ostr_filename.c_str());
      Test::HtmlOutput *phtmlout=dynamic_cast<Test::HtmlOutput *>(pout);

      phtmlout->generate(ostr, true, datetime);

      ostr.close();
    }

    delete pout;
  }

  return rtn;
}

{'fraction_non_alphanumeric': 0.16485679381023483, 'fraction_numerical': 0.004343694855436405, 'mean_word_length': 3.7609046849757672, 'pattern_counts': {'":': 0, '<': 207, '<?xml version=': 0, '>': 137, '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': '2650365', 'n_tokens_mistral': 5093, 'n_tokens_neox': 5062, 'n_words': 805}