mirror of
https://github.com/bolero-MURAKAMI/Sprout
synced 2025-08-03 12:49:50 +00:00
net.endian: resolution dependence on Boost
This commit is contained in:
parent
74669a5a8a
commit
f2c09dd3af
139 changed files with 4800 additions and 202 deletions
87
libs/test/random/test/distribution_generic.hpp
Normal file
87
libs/test/random/test/distribution_generic.hpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#ifndef SPROUT_LIBS_RANDOM_TEST_DISTRIBUTION_GENERIC_HPP
|
||||
#define SPROUT_LIBS_RANDOM_TEST_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_BOTH_ASSERT(dist1.min() <= dist1.max());
|
||||
|
||||
// param
|
||||
TESTSPR_BOTH_ASSERT(parm == dist1.param());
|
||||
{
|
||||
auto dist_temp = Distribution();
|
||||
dist_temp.param(parm);
|
||||
TESTSPR_ASSERT(dist_temp == dist1);
|
||||
}
|
||||
|
||||
// operator==
|
||||
// operator!=
|
||||
TESTSPR_BOTH_ASSERT(dist1 == dist2);
|
||||
TESTSPR_BOTH_ASSERT(!(dist1 != dist2));
|
||||
|
||||
{
|
||||
std::string s;
|
||||
|
||||
// operator<<
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << dist1;
|
||||
// ??? WORKAROUND: for Clang
|
||||
#if !defined(__clang__)
|
||||
TESTSPR_ASSERT(!!os);
|
||||
#endif
|
||||
s = os.str();
|
||||
}
|
||||
|
||||
auto dist_temp = Distribution();
|
||||
|
||||
// operator>>
|
||||
{
|
||||
std::istringstream is(s);
|
||||
is >> dist_temp;
|
||||
// ??? WORKAROUND: for Clang
|
||||
#if !defined(__clang__)
|
||||
TESTSPR_ASSERT(!!is);
|
||||
#endif
|
||||
}
|
||||
|
||||
TESTSPR_ASSERT(dist_temp == dist1);
|
||||
}
|
||||
|
||||
// operator()
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto eng = Engine(SPROUT_UNIQUE_SEED);
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto rnd = dist1(eng);
|
||||
|
||||
// result
|
||||
TESTSPR_BOTH_ASSERT(dist1.min() <= rnd.result());
|
||||
TESTSPR_BOTH_ASSERT(rnd.result() <= dist1.max());
|
||||
|
||||
// engine
|
||||
TESTSPR_BOTH_ASSERT(rnd.engine().min() <= rnd.engine().max());
|
||||
|
||||
// distribution
|
||||
TESTSPR_BOTH_ASSERT(rnd.distribution().min() <= rnd.distribution().max());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef SPROUT_LIBS_RANDOM_TEST_DISTRIBUTION_GENERIC_HPP
|
73
libs/test/random/test/engine_generic.hpp
Normal file
73
libs/test/random/test/engine_generic.hpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#ifndef SPROUT_LIBS_RANDOM_TEST_ENGINE_GENERIC_HPP
|
||||
#define SPROUT_LIBS_RANDOM_TEST_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_BOTH_ASSERT(eng1.min() <= eng1.max());
|
||||
|
||||
// operator==
|
||||
// operator!=
|
||||
TESTSPR_BOTH_ASSERT(eng1 == eng1);
|
||||
TESTSPR_BOTH_ASSERT(!(eng1 == eng2));
|
||||
TESTSPR_BOTH_ASSERT(eng1 != eng2);
|
||||
TESTSPR_BOTH_ASSERT(!(eng1 != eng1));
|
||||
|
||||
{
|
||||
std::string s;
|
||||
|
||||
// operator<<
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << eng1;
|
||||
// ??? WORKAROUND: for Clang
|
||||
#if !defined(__clang__)
|
||||
TESTSPR_ASSERT(!!os);
|
||||
#endif
|
||||
|
||||
s = os.str();
|
||||
}
|
||||
|
||||
auto eng_temp = Engine();
|
||||
|
||||
// operator>>
|
||||
{
|
||||
std::istringstream is(s);
|
||||
is >> eng_temp;
|
||||
// ??? WORKAROUND: for Clang
|
||||
#if !defined(__clang__)
|
||||
TESTSPR_ASSERT(!!is);
|
||||
#endif
|
||||
}
|
||||
|
||||
//TESTSPR_ASSERT(eng_temp == eng1);
|
||||
}
|
||||
|
||||
// operator()
|
||||
{
|
||||
SPROUT_STATIC_CONSTEXPR auto rnd = eng1();
|
||||
|
||||
// result
|
||||
TESTSPR_BOTH_ASSERT(eng1.min() <= rnd.result());
|
||||
TESTSPR_BOTH_ASSERT(rnd.result() <= eng1.max());
|
||||
|
||||
// engine
|
||||
TESTSPR_BOTH_ASSERT(rnd.engine().min() <= rnd.engine().max());
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace testspr
|
||||
|
||||
#endif // #ifndef SPROUT_LIBS_RANDOM_TEST_ENGINE_GENERIC_HPP
|
Loading…
Add table
Add a link
Reference in a new issue