<commit_before>//  (C) Copyright <NAME> 2011.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
//  File        : $RCSfile$
//
//  Version     : $Revision: 74248 $
//
//  Description : implementation of test tools
// ***************************************************************************

#ifndef BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER
#define BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER

// Boost.Test
#include <boost/test/tools/predicate_result.hpp>
#ifndef BOOST_TEST_PROD
#include <boost/test/unit_test_log.hpp>
#endif

#include <boost/test/tools/floating_point_comparison.hpp>
#include <boost/test/tools/assertion.hpp>

#include <boost/test/detail/config.hpp>
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/detail/workaround.hpp>

#include <boost/test/utils/wrap_stringstream.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
#include <boost/test/utils/lazy_ostream.hpp>

// Boost
#include <boost/limits.hpp>

#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_abstract.hpp>

#include <boost/mpl/or.hpp>

// STL
#include <cstddef>          // for std::size_t
#include <iosfwd>
#include <ios>              // for std::boolalpha
#include <climits>          // for CHAR_BIT

#ifdef BOOST_MSVC
# pragma warning(disable: 4127) // conditional expression is constant
#endif

#include <boost/test/detail/suppress_warnings.hpp>

//____________________________________________________________________________//

// ************************************************************************** //
// **************                    TOOL BOX                  ************** //
// ************************************************************************** //

namespace boost {
namespace test_tools {

typedef unit_test::const_string      const_string;

namespace { bool dummy_cond = false; }

// ************************************************************************** //
// **************                print_log_value               ************** //
// ************************************************************************** //

template<typename T>
struct print_log_value {
    void    operator()( std::ostream& ostr, T const& t )
    {
        // avoid warning: 'boost::test_tools::<unnamed>::dummy_cond' defined but not used
        if( ::boost::test_tools::dummy_cond ) {}

        typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;

        set_precision( ostr, cant_use_nl() );

        ostr << t; // by default print the value
    }

    void set_precision( std::ostream& ostr, mpl::false_ )
    {
        if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
            ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
        /*
        This needs a test for support of max_digits10 to avoid failures on platforms that do not support.
        if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 )
            ostr.precision( 2 + std::numeric_limits<T>::max_digits10);
            // Assume that max_digits10 is provided for all radix 10 as they are quite new,
            // and anyway Kahan formula will not work for decimal.
        */
    }

    void set_precision( std::ostream&, mpl::true_ ) {}
};

//____________________________________________________________________________//

#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T, std::size_t N >
struct print_log_value< T[N] > {
    void    operator()( std::ostream& ostr, T const* t )
    {
        ostr << t;
    }
};
#endif

//____________________________________________________________________________//
<commit_msg>changed to test for support of max_digits10 isuing  BOOST_NO_NUMERIC_LIMITS_LOWEST is a proxy for support of max_digits10.<commit_after>//  (C) Copyright <NAME> 2011.
//  Distributed under the Boost Software License, Version 1.0.
//  (See accompanying file LICENSE_1_0.txt or copy at
//  http://www.boost.org/LICENSE_1_0.txt)

//  See http://www.boost.org/libs/test for the library home page.
//
//  File        : $RCSfile$
//
//  Version     : $Revision: 74248 $
//
//  Description : implementation of test tools
// ***************************************************************************

#ifndef BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER
#define BOOST_TEST_TEST_TOOLS_IMPL_HPP_012705GER

// Boost.Test
#include <boost/test/tools/predicate_result.hpp>
#ifndef BOOST_TEST_PROD
#include <boost/test/unit_test_log.hpp>
#endif

#include <boost/test/tools/floating_point_comparison.hpp>
#include <boost/test/tools/assertion.hpp>

#include <boost/test/detail/config.hpp>
#include <boost/test/detail/global_typedef.hpp>
#include <boost/test/detail/workaround.hpp>

#include <boost/test/utils/wrap_stringstream.hpp>
#include <boost/test/utils/basic_cstring/io.hpp>
#include <boost/test/utils/lazy_ostream.hpp>

// Boost
#include <boost/limits.hpp>

#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/is_function.hpp>
#include <boost/type_traits/is_abstract.hpp>

#include <boost/mpl/or.hpp>

// STL
#include <cstddef>          // for std::size_t
#include <iosfwd>
#include <ios>              // for std::boolalpha
#include <climits>          // for CHAR_BIT

#ifdef BOOST_MSVC
# pragma warning(disable: 4127) // conditional expression is constant
#endif

#include <boost/test/detail/suppress_warnings.hpp>

//____________________________________________________________________________//

// ************************************************************************** //
// **************                    TOOL BOX                  ************** //
// ************************************************************************** //

namespace boost {
namespace test_tools {

typedef unit_test::const_string      const_string;

namespace { bool dummy_cond = false; }

// ************************************************************************** //
// **************                print_log_value               ************** //
// ************************************************************************** //

template<typename T>
struct print_log_value {
    void    operator()( std::ostream& ostr, T const& t )
    {
        // avoid warning: 'boost::test_tools::<unnamed>::dummy_cond' defined but not used
        if( ::boost::test_tools::dummy_cond ) {}

        typedef typename mpl::or_<is_array<T>,is_function<T>,is_abstract<T> >::type cant_use_nl;

        set_precision( ostr, cant_use_nl() );

        ostr << t; // by default print the value
    }

    void set_precision( std::ostream& ostr, mpl::false_ )
    {
        if( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 2 )
        {
            ostr.precision( 2 + std::numeric_limits<T>::digits * 301/1000 );
        }
        else if ( std::numeric_limits<T>::is_specialized && std::numeric_limits<T>::radix == 10 )
        {
#ifdef BOOST_NO_NUMERIC_LIMITS_LOWEST
// No support for std::numeric_limits<double>::max_digits10;
// so guess that a couple of guard digits more than digits10 will display any difference.
           ostr.precision( 2 + std::numeric_limits<T>::digits10 );
#else
  // std::numeric_limits<double>::max_digits10; IS supported.
  // Any noisy or guard digits needed to display any difference are included in max_digits10.
           ostr.precision( std::numeric_limits<T>::max_digits10 );
#endif
       }
       // else if T is not specialized, then will just get the default precision of 6 digits.
    }

    void set_precision( std::ostream&, mpl::true_ ) {}
};

//____________________________________________________________________________//

#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template<typename T, std::size_t N >
struct print_log_value< T[N] > {
    void    operator()( std::ostream& ostr, T const* t )
    {
        ostr << t;
    }
};
#endif

//____________________________________________________________________________//

{'fraction_non_alphanumeric': 0.21649987795948256, 'fraction_numerical': 0.014522821576763486, 'mean_word_length': 3.826266195524146, 'pattern_counts': {'":': 0, '<': 84, '<?xml version=': 0, '>': 76, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '907866', 'n_tokens_mistral': 2550, 'n_tokens_neox': 2339, 'n_words': 508}