1 /*  _______________________________________________________________________
2 
3     DAKOTA: Design Analysis Kit for Optimization and Terascale Applications
4     Copyright 2014-2020 National Technology & Engineering Solutions of Sandia, LLC (NTESS).
5     This software is distributed under the GNU Lesser General Public License.
6     For more information, see the README file in the top Dakota directory.
7     _______________________________________________________________________ */
8 
9 // TODO: How to manage these tests, given that they require external
10 // tools and PATH settings? Maybe configure_file(pyprepro.py) and set env
11 // Maybe CMake Test property for ENVIRONMENT
12 
13 #include "dakota_preproc_util.hpp"
14 #include <boost/filesystem.hpp>
15 #define BOOST_TEST_MODULE dakota_preproc
16 #include <boost/test/included/unit_test.hpp>
17 
18 
BOOST_AUTO_TEST_CASE(test_pyprepro)19 BOOST_AUTO_TEST_CASE(test_pyprepro)
20 {
21   // generate an input and diff against the baseline
22   std::string tmpl_file("preproc_dakota.tmpl");
23   std::string gen_file = Dakota::pyprepro_input(tmpl_file);
24 
25   // TODO: check_equal_files() function with this test:
26   std::ifstream base_ifs("preproc_dakota.base");
27   std::ifstream test_ifs(gen_file);
28   std::istream_iterator<char> base_it(base_ifs), base_end;
29   std::istream_iterator<char> test_it(test_ifs), test_end;
30   BOOST_CHECK_EQUAL_COLLECTIONS(base_it, base_end, test_it, test_end);
31 
32   // remove generated file
33   boost::filesystem::remove(gen_file);
34 }
35