1 //////////////////////////////////////////////////////////////////////////////////////
2 // This file is distributed under the University of Illinois/NCSA Open Source License.
3 // See LICENSE file in top directory for details.
4 //
5 // Copyright (c) 2017 Jeongnim Kim and QMCPACK developers.
6 //
7 // File developed by:  Mark Dewing, mdewing@anl.gov Argonne National Laboratory
8 //
9 // File created by: Mark Dewing, mdewing@anl.gov Argonne National Laboratory
10 //////////////////////////////////////////////////////////////////////////////////////
11 
12 
13 #include "catch.hpp"
14 
15 
16 //#include "Utilities/RandomGenerator.h"
17 #include "Message/Communicate.h"
18 #include "OhmmsData/Libxml2Doc.h"
19 #include "OhmmsApp/RandomNumberControl.h"
20 
21 
22 #include <stdio.h>
23 #include <string>
24 
25 
26 namespace qmcplusplus
27 {
28 TEST_CASE("RandomNumberControl make_seeds", "[ohmmsapp]")
29 {
30   Communicate* c;
31   c = OHMMS::Controller;
32 
33   RandomNumberControl::make_seeds();
34 
35   REQUIRE(RandomNumberControl::Children.size() > 0);
36 }
37 
38 TEST_CASE("RandomNumberControl no random in xml", "[ohmmsapp]")
39 {
40   Communicate* c;
41   c = OHMMS::Controller;
42 
43   const char* xml_input = "<tmp></tmp>";
44 
45   Libxml2Document doc;
46   bool okay = doc.parseFromString(xml_input);
47   REQUIRE(okay);
48 
49   RandomNumberControl rnc;
50 
51   xmlXPathContextPtr context = doc.getXPathContext();
52   rnc.initialize(context);
53 }
54 
55 TEST_CASE("RandomNumberControl random in xml", "[ohmmsapp]")
56 {
57   Communicate* c;
58   c = OHMMS::Controller;
59 
60   const char* xml_input = "<tmp><random seed='0'></random></tmp>";
61 
62   Libxml2Document doc;
63   bool okay = doc.parseFromString(xml_input);
64   REQUIRE(okay);
65 
66   RandomNumberControl rnc;
67 
68   xmlXPathContextPtr context = doc.getXPathContext();
69   rnc.initialize(context);
70 
71 
72   rnc.write("rng_out", c);
73 
74   RandomNumberControl rnc2;
75   rnc2.read("rng_out", c);
76   // not sure what to test here - for now make sure it doesn't crash.
77 }
78 } // namespace qmcplusplus
79