CASM
AClustersApproachtoStatisticalMechanics
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules
QueryPlugin_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(QueryPluginTest)
16 
18 
19  test::ZrOProj proj;
20  proj.check_init();
21  proj.check_composition();
22  proj.check_enum();
23 
25 
26  auto cp = [&](std::string _filename) {
27 
28  fs::path filename(_filename);
29  fs::path src = "tests/unit/App" / filename;
30  BOOST_REQUIRE(fs::exists(src));
31 
32  fs::path dest = primclex.dir().query_plugins<Configuration>();
33  fs::create_directories(dest);
34  BOOST_REQUIRE(fs::exists(dest));
35 
36  fs::copy_file(src, dest / filename, fs::copy_option::overwrite_if_exists);
37  BOOST_REQUIRE(fs::exists(dest / filename));
38 
39  };
40 
41  // functor formatter
42  cp("TestCompN.hh");
43  cp("TestCompN.cc");
44 
45  // generic formatter
46  cp("TestConfigname.hh");
47  cp("TestConfigname.cc");
48 
49  // refresh to load plugins
50  primclex.refresh(true);
51 
52  auto check = [&](std::string str) {
53  CommandArgs args(str, &primclex, primclex.dir().root_dir(), Logging::null());
54  return !casm_api(args);
55  };
56 
57  BOOST_CHECK(check(R"(ccasm select -h)"));
58 
59  BOOST_CHECK(check(R"(ccasm select --set-on)"));
60 
61  BOOST_CHECK(check(R"(ccasm query -h p)"));
62 
63  BOOST_CHECK(check(R"(ccasm query -k test_comp_n)"));
64 
65  BOOST_CHECK(check(R"(ccasm query -k 'test_comp_n(Zr)')"));
66 
67  BOOST_CHECK(check(R"(ccasm query -k 'test_comp_n(O)')"));
68 
69  BOOST_CHECK(check(R"(ccasm query -k 'test_configname')"));
70 
71 }
72 
73 BOOST_AUTO_TEST_SUITE_END()
Data structure holding basic CASM command info.
fs::path dir
Definition: Proj.hh:34
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
fs::path root_dir() const
Return casm project directory path.
static Logging null()
Definition: Log.hh:267
PrimClex is the top-level data structure for a CASM project.
Definition: PrimClex.hh:52
BOOST_AUTO_TEST_CASE(Test1)
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.
void check_enum() override
Check "ccasm enum".
Definition: ZrOProj.hh:140
fs::path query_plugins() const
Return enumerators plugin dir.
virtual void check_init()
Check project initialization.
A Configuration represents the values of all degrees of freedom in a Supercell.
int casm_api(const CommandArgs &args)
Executes CASM commands specified by args.