diff options
| author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
| commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
| tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc | |
| parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
| download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip | |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc')
14 files changed, 674 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp new file mode 100644 index 00000000000..18c8947af6e --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/assign.pass.cpp @@ -0,0 +1,56 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// discard_block_engine& operator=(const discard_block_engine&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::ranlux24 E; + E e1(2); + e1(); + E e2(5); + e2 = e1; + assert(e1 == e2); + assert(e1() == e2()); + E::result_type k = e1(); + assert(e1 != e2); + assert(e2() == k); + assert(e1 == e2); +} + +void +test2() +{ + typedef std::ranlux48 E; + E e1(3); + e1(); + E e2(5); + e2 = e1; + assert(e1 == e2); + assert(e1() == e2()); + E::result_type k = e1(); + assert(e1 != e2); + assert(e2() == k); + assert(e1 == e2); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp new file mode 100644 index 00000000000..d6c64fa37dc --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/copy.pass.cpp @@ -0,0 +1,54 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// discard_block_engine(const discard_block_engine&); + +#include <random> +#include <cassert> + +void +test1() +{ + typedef std::ranlux24 E; + E e1; + e1(); + E e2 = e1; + assert(e1 == e2); + assert(e1() == e2()); + E::result_type k = e1(); + assert(e1 != e2); + assert(e2() == k); + assert(e1 == e2); +} + +void +test2() +{ + typedef std::ranlux48 E; + E e1; + e1(); + E e2 = e1; + assert(e1 == e2); + assert(e1() == e2()); + E::result_type k = e1(); + assert(e1 != e2); + assert(e2() == k); + assert(e1 == e2); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp new file mode 100644 index 00000000000..d6b8b33ad01 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_copy.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// explicit discard_block_engine(const Engine& e); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::ranlux24_base Engine; + typedef std::ranlux24 Adaptor; + Engine e; + Adaptor a(e); + assert(a.base() == e); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp new file mode 100644 index 00000000000..1e8e2fe6fbb --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_engine_move.pass.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// explicit discard_block_engine(const Engine& e); + +#include <random> +#include <cassert> + +int main() +{ + { + typedef std::ranlux24_base Engine; + typedef std::ranlux24 Adaptor; + Engine e; + Engine e0 = e; + Adaptor a(std::move(e0)); + assert(a.base() == e); + } +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp new file mode 100644 index 00000000000..dba254f1a73 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_result_type.pass.cpp @@ -0,0 +1,51 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// explicit discard_block_engine(result_type s = default_seed); + +#include <random> +#include <sstream> +#include <cassert> + +void +test1() +{ + const char* a = "15136306 8587749 2346244 16479026 15515802 9510553 " + "16090340 14501685 13839944 10789678 11581259 9590790 5840316 5953700 " + "13398366 8134459 16629731 6851902 15583892 1317475 4231148 9092691 " + "5707268 2355175 0 0"; + std::ranlux24 e1(0); + std::ostringstream os; + os << e1; + assert(os.str() == a); +} + +void +test2() +{ + const char* a = "10880375256626 126660097854724 33643165434010 " + "78293780235492 179418984296008 96783156950859 238199764491708 " + "34339434557790 155299155394531 29014415493780 209265474179052 " + "263777435457028 0 0"; + std::ranlux48 e1(0); + std::ostringstream os; + os << e1; + assert(os.str() == a); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp new file mode 100644 index 00000000000..b64d4b31682 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/ctor_sseq.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// template<class Sseq> explicit discard_block_engine(Sseq& q); + +#include <random> +#include <sstream> +#include <cassert> + +void +test1() +{ + const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 " + "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 " + "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 " + "889045 0 0"; + unsigned as[] = {3, 5, 7}; + std::seed_seq sseq(as, as+3); + std::ranlux24 e1(sseq); + std::ostringstream os; + os << e1; + assert(os.str() == a); +} + +void +test2() +{ + const char* a = "241408498702289 172342669275054 191026374555184 " + "61020585639411 231929771458953 142769679250755 198672786411514 " + "183712717244841 227473912549724 62843577252444 68782400568421 " + "159248704678140 0 0"; + unsigned as[] = {3, 5, 7}; + std::seed_seq sseq(as, as+3); + std::ranlux48 e1(sseq); + std::ostringstream os; + os << e1; + assert(os.str() == a); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp new file mode 100644 index 00000000000..ffdaebc1714 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/default.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// explicit discard_block_engine(); + +#include <random> +#include <cassert> + +void +test1() +{ + std::ranlux24 e1; + std::ranlux24 e2(std::ranlux24_base::default_seed); + assert(e1 == e2); + assert(e1() == 15039276); +} + +void +test2() +{ + std::ranlux48 e1; + std::ranlux48 e2(std::ranlux48_base::default_seed); + assert(e1 == e2); + assert(e1() == 23459059301164ull); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp new file mode 100644 index 00000000000..2dada0d6345 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/discard.pass.cpp @@ -0,0 +1,52 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// void discard(unsigned long long z); + +#include <random> +#include <cassert> + +void +test1() +{ + std::ranlux24 e1; + std::ranlux24 e2 = e1; + assert(e1 == e2); + e1.discard(3); + assert(e1 != e2); + e2(); + e2(); + e2(); + assert(e1 == e2); +} + +void +test2() +{ + std::ranlux48 e1; + std::ranlux48 e2 = e1; + assert(e1 == e2); + e1.discard(3); + assert(e1 != e2); + e2(); + e2(); + e2(); + assert(e1 == e2); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp new file mode 100644 index 00000000000..f819d6a9769 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/eval.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// result_type operator()(); + +#include <random> +#include <cassert> + +void +test1() +{ + std::ranlux24 e; + assert(e() == 15039276u); + assert(e() == 16323925u); + assert(e() == 14283486u); +} + +void +test2() +{ + std::ranlux48 e; + assert(e() == 23459059301164ull); + assert(e() == 28639057539807ull); + assert(e() == 276846226770426ull); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp new file mode 100644 index 00000000000..4b742f06a5e --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/io.pass.cpp @@ -0,0 +1,63 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// template <class charT, class traits, +// class Engine, size_t p, size_t r> +// basic_ostream<charT, traits>& +// operator<<(basic_ostream<charT, traits>& os, +// const discard_block_engine<Engine, p, r>& x); +// +// template <class charT, class traits, +// class Engine, size_t p, size_t r> +// basic_istream<charT, traits>& +// operator>>(basic_istream<charT, traits>& is, +// discard_block_engine<Engine, p, r>& x); + +#include <random> +#include <sstream> +#include <cassert> + +void +test1() +{ + typedef std::ranlux24 E; + E e1; + e1.discard(100); + std::ostringstream os; + os << e1; + std::istringstream is(os.str()); + E e2; + is >> e2; + assert(e1 == e2); +} + +void +test2() +{ + typedef std::ranlux48 E; + E e1; + e1.discard(100); + std::ostringstream os; + os << e1; + std::istringstream is(os.str()); + E e2; + is >> e2; + assert(e1 == e2); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp new file mode 100644 index 00000000000..2634aba3823 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/result_type.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine +// { +// public: +// // types +// typedef typename Engine::result_type result_type; + +#include <random> +#include <type_traits> + +void +test1() +{ + static_assert((std::is_same< + std::ranlux24::result_type, + std::uint_fast32_t>::value), ""); +} + +void +test2() +{ + static_assert((std::is_same< + std::ranlux48::result_type, + std::uint_fast64_t>::value), ""); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp new file mode 100644 index 00000000000..6a5ff14f77a --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_result_type.pass.cpp @@ -0,0 +1,50 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// void seed(result_type s = default_seed); + +#include <random> +#include <cassert> + +void +test1() +{ + for (int s = 0; s < 20; ++s) + { + typedef std::ranlux24 E; + E e1(s); + E e2; + e2.seed(s); + assert(e1 == e2); + } +} + +void +test2() +{ + for (int s = 0; s < 20; ++s) + { + typedef std::ranlux48 E; + E e1(s); + E e2; + e2.seed(s); + assert(e1 == e2); + } +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp new file mode 100644 index 00000000000..0da09a379e6 --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/seed_sseq.pass.cpp @@ -0,0 +1,48 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine + +// template<class Sseq> void seed(Sseq& q); + +#include <random> +#include <cassert> + +void +test1() +{ + unsigned a[] = {3, 5, 7}; + std::seed_seq sseq(a, a+3); + std::ranlux24 e1; + std::ranlux24 e2(sseq); + assert(e1 != e2); + e1.seed(sseq); + assert(e1 == e2); +} + +void +test2() +{ + unsigned a[] = {3, 5, 7}; + std::seed_seq sseq(a, a+3); + std::ranlux48 e1; + std::ranlux48 e2(sseq); + assert(e1 != e2); + e1.seed(sseq); + assert(e1 == e2); +} + +int main() +{ + test1(); + test2(); +} diff --git a/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp new file mode 100644 index 00000000000..53e4c29affc --- /dev/null +++ b/libcxx/test/std/numerics/rand/rand.adapt/rand.adapt.disc/values.pass.cpp @@ -0,0 +1,60 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <random> + +// template<class Engine, size_t p, size_t r> +// class discard_block_engine +// { +// public: +// // types +// typedef typename Engine::result_type result_type; +// +// // engine characteristics +// static constexpr size_t block_size = p; +// static constexpr size_t used_block = r; +// static constexpr result_type min() { return Engine::min(); } +// static constexpr result_type max() { return Engine::max(); } + +#include <random> +#include <type_traits> +#include <cassert> + +template <class _Tp> +void where(const _Tp &) {} + +void +test1() +{ + typedef std::ranlux24 E; + static_assert((E::block_size == 223), ""); + static_assert((E::used_block == 23), ""); + /*static_*/assert((E::min() == 0)/*, ""*/); + /*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/); + where(E::block_size); + where(E::used_block); +} + +void +test2() +{ + typedef std::ranlux48 E; + static_assert((E::block_size == 389), ""); + static_assert((E::used_block == 11), ""); + /*static_*/assert((E::min() == 0)/*, ""*/); + /*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/); + where(E::block_size); + where(E::used_block); +} + +int main() +{ + test1(); + test2(); +} |

