// -*- C++ -*-
-// Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+// Copyright (C) 2005-2024 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License as published by the Free Software
-// Foundation; either version 2, or (at your option) any later
+// Foundation; either version 3, or (at your option) any later
// version.
// This library is distributed in the hope that it will be useful, but
// General Public License for more details.
// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, USA.
-
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
+// along with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
struct rand_reg_test
{
public:
- rand_reg_test(size_t seed, size_t n, size_t m, double tp, double ip,
- double dp, double ep, double cp, double mp, bool d)
- : m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep),
+ rand_reg_test(size_t seed, size_t n, size_t m, double tp, double ip,
+ double dp, double ep, double cp, double mp, bool d)
+ : m_sd(seed), m_n(n), m_m(m), m_tp(tp), m_ip(ip), m_dp(dp), m_ep(ep),
m_cp(cp), m_mp(mp), m_disp(d)
- { }
+ {
+ if (m_disp)
+ xml_test_rand_regression_formatter(seed, n, m, tp, ip, ep, cp, mp);
+ }
template<typename Cntnr>
void
operator()(Cntnr)
{
unsigned long ul = static_cast<unsigned long>(m_sd);
- container_rand_regression_test<Cntnr> t(ul, m_n, m_n, m_tp, m_ip, m_dp,
+ container_rand_regression_test<Cntnr> t(ul, m_n, m_n, m_tp, m_ip, m_dp,
m_ep, m_cp, m_mp, m_disp);
t();
}
usage(const std::string& r_name);
void
- verify_params(size_t&, size_t&, size_t&,
+ verify_params(size_t&, size_t&, size_t&,
double&, double&, double&, double&, double&, double&, bool&);
} // namespace detail
// Sane defaults.
size_t n = iter;
size_t m = keys;
- size_t sd = 0; // 0 = time-determined arbitrary
+ size_t sd = twister_rand_gen::get_time_determined_seed();
double tp = 0.2;
double ip = 0.6;
double dp = 0.1;
- double ep = 0.2;
+ double ep = 0.2;
double cp = 0.001;
double mp = 1;
- bool disp = false; // show progress
+ bool disp = true; // show progress
try
{
return -2;
};
- xml_test_rand_regression_formatter* p_fmt = NULL;
- if (sd == 0)
- sd = twister_rand_gen::get_time_determined_seed();
- if (disp)
- p_fmt = new xml_test_rand_regression_formatter(sd, n, m, tp, ip, dp,
- ep, cp, mp);
-
try
{
detail::rand_reg_test tst(sd, n, m, tp, ip, dp, ep, cp, mp, disp);
catch(...)
{
std::cerr << "Test failed with seed " << sd << std::endl;
- if (disp)
- delete p_fmt;
- return -1;
+ throw;
}
- if (disp)
- delete p_fmt;
return 0;
}
namespace detail
{
- void
+ inline void
usage(const std::string& name)
{
using namespace std;
cerr << "'t' or 'f' determine whether progress will be displayed" << endl;
}
- void
- verify_params(size_t& r_seed, size_t& r_n,
- size_t& r_m, double& r_tp, double& r_ip, double& r_dp,
+ inline void
+ verify_params(size_t& r_seed, size_t& r_n,
+ size_t& r_m, double& r_tp, double& r_ip, double& r_dp,
double& r_ep, double& r_cp, double& r_mp, bool& r_d)
{
verify_prob(r_tp);