15a83710eSEric Fiselier //===----------------------------------------------------------------------===//
25a83710eSEric Fiselier //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65a83710eSEric Fiselier //
75a83710eSEric Fiselier //===----------------------------------------------------------------------===//
85a83710eSEric Fiselier 
95a83710eSEric Fiselier // <random>
105a83710eSEric Fiselier 
115a83710eSEric Fiselier // template<class UIntType, size_t w, size_t s, size_t r>
125a83710eSEric Fiselier // class subtract_with_carry_engine;
135a83710eSEric Fiselier 
145a83710eSEric Fiselier // template<class Sseq> explicit subtract_with_carry_engine(Sseq& q);
155a83710eSEric Fiselier 
1688ffc727SLouis Dionne // Serializing/deserializing the state of the RNG requires iostreams
17*a7f9895cSLouis Dionne // UNSUPPORTED: no-localization
1888ffc727SLouis Dionne 
195a83710eSEric Fiselier #include <random>
205a83710eSEric Fiselier #include <sstream>
215a83710eSEric Fiselier #include <cassert>
225a83710eSEric Fiselier 
237fc6a556SMarshall Clow #include "test_macros.h"
247fc6a556SMarshall Clow 
255a83710eSEric Fiselier void
test1()265a83710eSEric Fiselier test1()
275a83710eSEric Fiselier {
285a83710eSEric Fiselier     const char* a = "13604817 711567 9760686 13278398 3323440 175548 5553651 "
295a83710eSEric Fiselier     "3028863 10748297 2216688 275779 14778841 14438394 9483441 4229545 "
305a83710eSEric Fiselier     "14657301 12636508 15978210 1653340 1718567 9272421 14302862 7940348 "
315a83710eSEric Fiselier     "889045 0";
325a83710eSEric Fiselier     unsigned as[] = {3, 5, 7};
335a83710eSEric Fiselier     std::seed_seq sseq(as, as+3);
345a83710eSEric Fiselier     std::ranlux24_base e1(sseq);
355a83710eSEric Fiselier     std::ostringstream os;
365a83710eSEric Fiselier     os << e1;
375a83710eSEric Fiselier     assert(os.str() == a);
385a83710eSEric Fiselier }
395a83710eSEric Fiselier 
405a83710eSEric Fiselier void
test2()415a83710eSEric Fiselier test2()
425a83710eSEric Fiselier {
435a83710eSEric Fiselier     const char* a = "241408498702289 172342669275054 191026374555184 "
445a83710eSEric Fiselier     "61020585639411 231929771458953 142769679250755 198672786411514 "
455a83710eSEric Fiselier     "183712717244841 227473912549724 62843577252444 68782400568421 "
465a83710eSEric Fiselier     "159248704678140 0";
475a83710eSEric Fiselier     unsigned as[] = {3, 5, 7};
485a83710eSEric Fiselier     std::seed_seq sseq(as, as+3);
495a83710eSEric Fiselier     std::ranlux48_base e1(sseq);
505a83710eSEric Fiselier     std::ostringstream os;
515a83710eSEric Fiselier     os << e1;
525a83710eSEric Fiselier     assert(os.str() == a);
535a83710eSEric Fiselier }
545a83710eSEric Fiselier 
main(int,char **)552df59c50SJF Bastien int main(int, char**)
565a83710eSEric Fiselier {
575a83710eSEric Fiselier     test1();
585a83710eSEric Fiselier     test2();
592df59c50SJF Bastien 
602df59c50SJF Bastien   return 0;
615a83710eSEric Fiselier }
62