mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
testspr テスト追加
This commit is contained in:
parent
240c2bee1d
commit
7479f20c46
72 changed files with 6810 additions and 0 deletions
16
testspr/sprout/random/additive_combine.hpp
Normal file
16
testspr/sprout/random/additive_combine.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_ADDITIVE_COMBINE_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_ADDITIVE_COMBINE_HPP
|
||||
|
||||
#include <sprout/random/additive_combine.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_additive_combine_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::ecuyer1988>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_ADDITIVE_COMBINE_HPP
|
16
testspr/sprout/random/bernoulli_distribution.hpp
Normal file
16
testspr/sprout/random/bernoulli_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_BERNOULLI_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_BERNOULLI_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/bernoulli_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_bernoulli_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::bernoulli_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_BERNOULLI_DISTRIBUTION_HPP
|
16
testspr/sprout/random/binomial_distribution.hpp
Normal file
16
testspr/sprout/random/binomial_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_BINOMIAL_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_BINOMIAL_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/binomial_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_binomial_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::binomial_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_BINOMIAL_DISTRIBUTION_HPP
|
82
testspr/sprout/random/distribution_generic.hpp
Normal file
82
testspr/sprout/random/distribution_generic.hpp
Normal file
|
@ -0,0 +1,82 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_DISTRIBUTION_GENERIC_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_DISTRIBUTION_GENERIC_HPP
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <sprout/random/linear_congruential.hpp>
|
||||
#include <sprout/random/unique_seed.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
template<typename Distribution, typename Engine = sprout::random::minstd_rand0>
|
||||
void random_distribution_test_generic() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto parm = typename Distribution::param_type();
|
||||
|
||||
SPROUT_STATIC_CONSTEXPR auto dist1 = Distribution(parm);
|
||||
SPROUT_STATIC_CONSTEXPR auto dist2 = Distribution(parm);
|
||||
|
||||
// min
|
||||
// max
|
||||
TESTSPR_DOUBLE_ASSERT(dist1.min() <= dist1.max());
|
||||
|
||||
// param
|
||||
TESTSPR_DOUBLE_ASSERT(parm == dist1.param());
|
||||
{
|
||||
auto dist_temp = Distribution();
|
||||
dist_temp.param(parm);
|
||||
TESTSPR_ASSERT(dist_temp == dist1);
|
||||
}
|
||||
|
||||
// operator==
|
||||
// operator!=
|
||||
TESTSPR_DOUBLE_ASSERT(dist1 == dist2);
|
||||
TESTSPR_DOUBLE_ASSERT(!(dist1 != dist2));
|
||||
|
||||
{
|
||||
std::string s;
|
||||
|
||||
// operator<<
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << dist1;
|
||||
TESTSPR_ASSERT(os);
|
||||
|
||||
s = os.str();
|
||||
}
|
||||
|
||||
auto dist_temp = Distribution();
|
||||
|
||||
// operator>>
|
||||
{
|
||||
std::istringstream is(s);
|
||||
is >> dist_temp;
|
||||
TESTSPR_ASSERT(is);
|
||||
}
|
||||
|
||||
TESTSPR_ASSERT(dist_temp == dist1);
|
||||
}
|
||||
|
||||
// operator()
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto eng = Engine(SPROUT_UNIQUE_SEED);
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto rnd = dist1(eng);
|
||||
|
||||
// result
|
||||
TESTSPR_DOUBLE_ASSERT(dist1.min() <= rnd.result());
|
||||
TESTSPR_DOUBLE_ASSERT(rnd.result() <= dist1.max());
|
||||
|
||||
// engine
|
||||
TESTSPR_DOUBLE_ASSERT(rnd.engine().min() <= rnd.engine().max());
|
||||
|
||||
// distribution
|
||||
TESTSPR_DOUBLE_ASSERT(rnd.distribution().min() <= rnd.distribution().max());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_DISTRIBUTION_GENERIC_HPP
|
71
testspr/sprout/random/engine_generic.hpp
Normal file
71
testspr/sprout/random/engine_generic.hpp
Normal file
|
@ -0,0 +1,71 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_ENGINE_GENERIC_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_ENGINE_GENERIC_HPP
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <sprout/random/unique_seed.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
template<typename Engine>
|
||||
void random_engine_test_generic() {
|
||||
using namespace sprout;
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto eng1 = Engine(SPROUT_UNIQUE_SEED);
|
||||
SPROUT_STATIC_CONSTEXPR auto eng2 = Engine(SPROUT_UNIQUE_SEED);
|
||||
|
||||
// min
|
||||
// max
|
||||
TESTSPR_DOUBLE_ASSERT(eng1.min() <= eng1.max());
|
||||
|
||||
// operator==
|
||||
// operator!=
|
||||
// TESTSPR_DOUBLE_ASSERT(eng1 == eng1);
|
||||
// TESTSPR_DOUBLE_ASSERT(!(eng1 == eng2));
|
||||
// TESTSPR_DOUBLE_ASSERT(eng1 != eng2);
|
||||
// TESTSPR_DOUBLE_ASSERT(!(eng1 != eng1));
|
||||
TESTSPR_ASSERT(eng1 == eng1);
|
||||
TESTSPR_ASSERT(!(eng1 == eng2));
|
||||
TESTSPR_ASSERT(eng1 != eng2);
|
||||
TESTSPR_ASSERT(!(eng1 != eng1));
|
||||
|
||||
{
|
||||
std::string s;
|
||||
|
||||
// operator<<
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << eng1;
|
||||
TESTSPR_ASSERT(os);
|
||||
|
||||
s = os.str();
|
||||
}
|
||||
|
||||
auto eng_temp = Engine();
|
||||
|
||||
// operator>>
|
||||
{
|
||||
std::istringstream is(s);
|
||||
is >> eng_temp;
|
||||
TESTSPR_ASSERT(is);
|
||||
}
|
||||
|
||||
//TESTSPR_ASSERT(eng_temp == eng1);
|
||||
}
|
||||
|
||||
// operator()
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto rnd = eng1();
|
||||
|
||||
// result
|
||||
TESTSPR_DOUBLE_ASSERT(eng1.min() <= rnd.result());
|
||||
TESTSPR_DOUBLE_ASSERT(rnd.result() <= eng1.max());
|
||||
|
||||
// engine
|
||||
TESTSPR_DOUBLE_ASSERT(rnd.engine().min() <= rnd.engine().max());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_ENGINE_GENERIC_HPP
|
16
testspr/sprout/random/geometric_distribution.hpp
Normal file
16
testspr/sprout/random/geometric_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/geometric_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_geometric_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::geometric_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_GEOMETRIC_DISTRIBUTION_HPP
|
16
testspr/sprout/random/inversive_congruential.hpp
Normal file
16
testspr/sprout/random/inversive_congruential.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
|
||||
|
||||
#include <sprout/random/linear_congruential.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_inversive_congruential_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::hellekalek1995>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_INVERSIVE_CONGRUENTIAL_HPP
|
18
testspr/sprout/random/linear_congruential.hpp
Normal file
18
testspr/sprout/random/linear_congruential.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP
|
||||
|
||||
#include <sprout/random/linear_congruential.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_linear_congruential_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::minstd_rand0>();
|
||||
testspr::random_engine_test_generic<sprout::random::minstd_rand>();
|
||||
testspr::random_engine_test_generic<sprout::random::rand48>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_LINEAR_CONGRUENTIAL_HPP
|
18
testspr/sprout/random/mersenne_twister.hpp
Normal file
18
testspr/sprout/random/mersenne_twister.hpp
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_MERSENNE_TWISTER_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_MERSENNE_TWISTER_HPP
|
||||
|
||||
#include <sprout/random/mersenne_twister.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_mersenne_twister_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::mt11213b>();
|
||||
//testspr::random_engine_test_generic<sprout::random::mt19937>();
|
||||
//testspr::random_engine_test_generic<sprout::random::mt19937_64>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_MERSENNE_TWISTER_HPP
|
16
testspr/sprout/random/normal_distribution.hpp
Normal file
16
testspr/sprout/random/normal_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/normal_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_normal_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::normal_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_NORMAL_DISTRIBUTION_HPP
|
17
testspr/sprout/random/shuffle_order.hpp
Normal file
17
testspr/sprout/random/shuffle_order.hpp
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_SHUFFLE_ORDER_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_SHUFFLE_ORDER_HPP
|
||||
|
||||
#include <sprout/random/shuffle_order.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_shuffle_order_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::knuth_b>();
|
||||
testspr::random_engine_test_generic<sprout::random::kreutzer1986>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_SHUFFLE_ORDER_HPP
|
16
testspr/sprout/random/taus88.hpp
Normal file
16
testspr/sprout/random/taus88.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_TAUS88_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_TAUS88_HPP
|
||||
|
||||
#include <sprout/random/taus88.hpp>
|
||||
#include <testspr/sprout/random/engine_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_taus88_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_engine_test_generic<sprout::random::taus88>();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_TAUS88_HPP
|
16
testspr/sprout/random/uniform_01.hpp
Normal file
16
testspr/sprout/random/uniform_01.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_01_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_UNIFORM_01_HPP
|
||||
|
||||
#include <sprout/random/uniform_01.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_uniform_01_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::uniform_01<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_01_HPP
|
16
testspr/sprout/random/uniform_int_distribution.hpp
Normal file
16
testspr/sprout/random/uniform_int_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/uniform_int_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_uniform_int_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::uniform_int_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_INT_DISTRIBUTION_HPP
|
16
testspr/sprout/random/uniform_real_distribution.hpp
Normal file
16
testspr/sprout/random/uniform_real_distribution.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_REAL_DISTRIBUTION_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_UNIFORM_REAL_DISTRIBUTION_HPP
|
||||
|
||||
#include <sprout/random/uniform_real_distribution.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_uniform_real_distribution_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::uniform_real_distribution<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_REAL_DISTRIBUTION_HPP
|
16
testspr/sprout/random/uniform_smallint.hpp
Normal file
16
testspr/sprout/random/uniform_smallint.hpp
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_SMALLINT_HPP
|
||||
#define TESTSPR_SPROUT_RANDOM_UNIFORM_SMALLINT_HPP
|
||||
|
||||
#include <sprout/random/uniform_smallint.hpp>
|
||||
#include <testspr/sprout/random/distribution_generic.hpp>
|
||||
#include <testspr/tools.hpp>
|
||||
|
||||
namespace testspr {
|
||||
void random_uniform_smallint_test() {
|
||||
using namespace sprout;
|
||||
|
||||
testspr::random_distribution_test_generic<sprout::random::uniform_smallint<> >();
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef TESTSPR_SPROUT_RANDOM_UNIFORM_SMALLINT_HPP
|
Loading…
Add table
Add a link
Reference in a new issue