<commit_before>/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, version 1.0 RC 1        *
*                (c) 2006-2011 INRIA, USTL, UJF, CNRS, MGH                    *
*                                                                             *
* This library is free software; you can redistribute it and/or modify it     *
* under the terms of the GNU Lesser General Public License as published by    *
* the Free Software Foundation; either version 2.1 of the License, or (at     *
* your option) any later version.                                             *
*                                                                             *
* This library 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 Lesser General Public License *
* for more details.                                                           *
*                                                                             *
* You should have received a copy of the GNU Lesser General Public License    *
* along with this library; if not, write to the Free Software Foundation,     *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
*******************************************************************************
*                              SOFA :: Framework                              *
*                                                                             *
* Authors: The SOFA Team (see Authors.txt)                                    *
*                                                                             *
* Contact information: <EMAIL>                             *
******************************************************************************/
#ifndef SOFA_HELPER_UnitTest_H
#define SOFA_HELPER_UnitTest_H

#include <iostream>
#include <sstream>
#include <sofa/defaulttype/Vec.h>
#include <sofa/helper/Quater.h>

namespace sofa
{

namespace helper
{

/** Base class for testing functions.
  To implement a new test, derive this class and implement the succeeds() method.
  Messages can be issued using the serr stream. They will be displayed or not, along with the name of the test, depending on the value of the verbose static member.
  */
struct UnitTest
{
    static bool verbose;  ///< Condition for printing test name, comments and results of the test.
    std::string name;     ///< Test name. Can be a long string explaining what the test checks.
    std::ostringstream  msg;  ///< Output stream used to issue messages during the tests. Displayed or discarded, depending on the value of variable verbose.

    /// The test name can be a long string explaining what the test checks.
    UnitTest( std::string testName );

    /// Runs the test and return true in case of failure. Optionally print begin and end messages, depending on the verbose variable
    bool fails();

    /// Perform the test and return true in case of success.
    virtual bool succeeds()=0;


    /** @name Helpers
     *  Helper Functions to more easily create tests and check the results.
     */
    //@{
    /// A very small value. Can be used to check if an error is small enough.
    virtual double epsilon() const { return 1.0e-10; }

    /** Velocity of a rigid body at a given point, based on its angular velocity and its linear velocity at another point.
      \param omega angular velocity
      \param v known linear velocity
      \param pv point where the linear velocity is known<commit_msg>r12030/sofa-dev : FIX build warnings<commit_after>/******************************************************************************
*       SOFA, Simulation Open-Framework Architecture, version 1.0 RC 1        *
*                (c) 2006-2011 INRIA, USTL, UJF, CNRS, MGH                    *
*                                                                             *
* This library is free software; you can redistribute it and/or modify it     *
* under the terms of the GNU Lesser General Public License as published by    *
* the Free Software Foundation; either version 2.1 of the License, or (at     *
* your option) any later version.                                             *
*                                                                             *
* This library 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 Lesser General Public License *
* for more details.                                                           *
*                                                                             *
* You should have received a copy of the GNU Lesser General Public License    *
* along with this library; if not, write to the Free Software Foundation,     *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
*******************************************************************************
*                              SOFA :: Framework                              *
*                                                                             *
* Authors: The SOFA Team (see Authors.txt)                                    *
*                                                                             *
* Contact information: <EMAIL>                             *
******************************************************************************/
#ifndef SOFA_HELPER_UnitTest_H
#define SOFA_HELPER_UnitTest_H

#include <iostream>
#include <sstream>
#include <sofa/defaulttype/Vec.h>
#include <sofa/helper/Quater.h>

namespace sofa
{

namespace helper
{

/** Base class for testing functions.
  To implement a new test, derive this class and implement the succeeds() method.
  Messages can be issued using the serr stream. They will be displayed or not, along with the name of the test, depending on the value of the verbose static member.
  */
struct UnitTest
{
    static bool verbose;  ///< Condition for printing test name, comments and results of the test.
    std::string name;     ///< Test name. Can be a long string explaining what the test checks.
    std::ostringstream  msg;  ///< Output stream used to issue messages during the tests. Displayed or discarded, depending on the value of variable verbose.

    /// The test name can be a long string explaining what the test checks.
    UnitTest( std::string testName );
    virtual ~UnitTest() {}

    /// Runs the test and return true in case of failure. Optionally print begin and end messages, depending on the verbose variable
    bool fails();

    /// Perform the test and return true in case of success.
    virtual bool succeeds()=0;


    /** @name Helpers
     *  Helper Functions to more easily create tests and check the results.
     */
    //@{
    /// A very small value. Can be used to check if an error is small enough.
    virtual double epsilon() const { return 1.0e-10; }

    /** Velocity of a rigid body at a given point, based on its angular velocity and its linear velocity at another point.
      \param omega angular velocity
      \param v known linear velocity
      \param pv point where the linear velocity is known
{'fraction_non_alphanumeric': 0.12160694896851248, 'fraction_numerical': 0.008550488599348535, 'mean_word_length': 1.8019011406844105, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 40, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7298055', 'n_tokens_mistral': 1629, 'n_tokens_neox': 1513, 'n_words': 770}