CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
EnumeratorPlugin_test.cpp
Go to the documentation of this file.
1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
3 
6 
8 #include <boost/filesystem.hpp>
9 
10 #include "Common.hh"
12 
13 using namespace CASM;
14 
15 BOOST_AUTO_TEST_SUITE(EnumeratorPluginTest)
16 
18 
19  test::ZrOProj proj;
20  proj.check_init();
21  proj.check_composition();
22 
23  PrimClex primclex(proj.dir, null_log());
24 
25  auto cp = [&](std::string _filename) {
26 
27  fs::path filename(_filename);
28  fs::path src = "tests/unit/App" / filename;
29  BOOST_REQUIRE(fs::exists(src));
30 
31  fs::path dest = primclex.dir().enumerator_plugins();
32  fs::create_directories(dest);
33  BOOST_REQUIRE(fs::exists(dest));
34 
35  fs::copy_file(src, dest / filename, fs::copy_option::overwrite_if_exists);
36  BOOST_REQUIRE(fs::exists(dest / filename));
37 
38  };
39 
40  cp("TestEnum.hh");
41  cp("TestEnum.cc");
42 
43  // refresh to load plugins
44  primclex.refresh(true);
45 
46  auto check = [&](std::string str) {
47  CommandArgs args(str, &primclex, primclex.dir().root_dir(), primclex);
48  BOOST_CHECK(!enum_command(args));
49  };
50 
51  check(R"(enum -h)");
52 
53  check(R"(enum --desc TestEnum)");
54 
55  check(R"(enum --method TestEnum -i '{"supercells": {"max": 4}}')");
56 
57  BOOST_CHECK_EQUAL(std::distance(primclex.config_begin(), primclex.config_end()), 336);
58 
59 }
60 
61 BOOST_AUTO_TEST_SUITE_END()
Data structure holding basic CASM command info.
fs::path dir
Definition: Proj.hh:34
int enum_command(const CommandArgs &args)
Definition: enum.cc:51
const DirectoryStructure & dir() const
Definition: PrimClex.hh:112
PrimClex * primclex
Definition: settings.cc:101
void check_composition() override
Check "casm composition".
Definition: ZrOProj.hh:79
void refresh(bool read_settings=false, bool read_composition=false, bool read_chem_ref=false, bool read_configs=false, bool clear_clex=false)
Reload PrimClex data from settings.
Definition: PrimClex.cc:90
Main CASM namespace.
Definition: complete.cpp:8
Log & null_log()
Definition: Log.hh:211
config_iterator config_begin()
Configuration iterator: begin.
Definition: PrimClex.cc:371
config_iterator config_end()
Configuration iterator: end.
Definition: PrimClex.cc:379
fs::path enumerator_plugins() const
Return enumerators plugin dir.
BOOST_AUTO_TEST_CASE(Test1)
fs::path root_dir() const
Return casm project directory path.
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
bool check(std::string test, const jsonParser &expected, const jsonParser &calculated, fs::path test_cases_path, bool quiet, double tol=0.0)
Check expected JSON vs calculated JSON using BOOST_CHECK_EQUAL.
virtual void check_init()
Check project initialization.