1 #define BOOST_TEST_DYN_LINK
2 #include <boost/test/unit_test.hpp>
18 BOOST_AUTO_TEST_SUITE(ConfigIOTest)
22 using namespace ConfigIO;
27 auto prev_size = dict.
size();
29 BOOST_CHECK_MESSAGE(prev_size + 1 == dict.
size(), formatter.name());
51 check(ClexHullDist());
69 check(RelaxationStrain());
82 using namespace ConfigIO;
87 format_operator_add<Configuration>()
101 ss <<
"get iterator" << std::endl;
103 ss <<
"get ref from transform iterator" << std::endl;
105 (void) transform_ref;
106 ss <<
"get const ref from transform iterator" << std::endl;
108 (void) const_transform_ref;
110 ss <<
"get ref from iterator" << std::endl;
113 ss <<
"get pair ref from base iterator" << std::endl;
114 auto &pair_ref = *(it.
base());
116 ss <<
"get const pair ref from base iterator" << std::endl;
117 const auto &const_pair_ref = *(it.
base());
118 (void) const_pair_ref;
119 ss <<
"use ref from iterator, name: " << ref.
name() << std::endl;
123 ss <<
"name: " << it.
base()->second->name() << std::endl;
127 ss <<
"\n-----------------------\n";
129 std::vector<cloner> dict;
132 dict.emplace_back(format_operator_add<Configuration>());
133 dict.emplace_back(format_operator_sub<Configuration>());
134 dict.emplace_back(format_operator_eq<Configuration>());
136 ss <<
"get iterator" << std::endl;
137 auto it = dict.begin();
138 ss <<
"get ref from iterator" << std::endl;
140 ss <<
"use ref from iterator, name: " << ref.
name() << std::endl;
142 for(
auto it = dict.begin(); it != dict.end(); ++it) {
143 ss <<
"name: " << (*it)->name() << std::endl;
147 ss <<
"\n-----------------------\n";
149 std::map<std::string, cloner > dict;
152 dict[
"add"] = cloner(format_operator_add<Configuration>());
153 dict[
"sub"] = cloner(format_operator_sub<Configuration>());
154 dict[
"eq"] = cloner(format_operator_eq<Configuration>());
156 ss <<
"get iterator" << std::endl;
157 auto it = dict.begin();
158 ss <<
"get ref from iterator" << std::endl;
160 ss <<
"use ref from iterator, name: " << ref.
name() << std::endl;
162 for(
auto it = dict.begin(); it != dict.end(); ++it) {
163 ss <<
"name: " << it->second->name() << std::endl;
167 ss <<
"\n-----------------------\n";
168 auto adder = format_operator_add<Configuration>();
169 ss <<
"adder name: " << adder.name() << std::endl;
172 ss <<
"ptr adder name: " << ptr->
name() << std::endl;
175 ss <<
"cl_ptr adder name: " << cl_ptr->name() << std::endl;
178 ss <<
"other adder name: " << other->name() << std::endl;
181 ss <<
"another adder name: " << another->name() << std::endl;
183 ss <<
"\n-----------------------\n";
187 for(
auto it = dict.
begin(); it != dict.
end(); ++it) {
188 ss <<
"name: " << it->name() << std::endl;
205 log <<
"---- Comp -------------" << std::endl;
208 log <<
"name: " << it->name() <<
" comp: " <<
comp(*it).transpose() <<
" print: ";
209 comp.
print(*it, log);
213 log <<
"---- BaseValueFormatter Ptr -------------" << std::endl;
216 log <<
"name: " << it->name() <<
" value: " << (*value_ptr)(*it).transpose() <<
" print: ";
217 value_ptr->
print(*it, log);
221 log <<
"---- BaseDatumFormatter Ptr -------------" << std::endl;
224 log <<
"name: " << it->name() <<
" print: ";
225 datum_ptr->
print(*it, log);
233 BOOST_AUTO_TEST_SUITE_END()
void check_composition() override
Check "casm composition".
ConfigIO::Selected selected_in(const ConfigSelection< IsConst > &_selection)
An iterator over a UniqueMap.
ConfigIO::GenericConfigFormatter< double > relaxed_energy()
Eigen::VectorXd comp(const Configuration &config)
Returns parametric composition, as calculated using PrimClex::param_comp.
Calculate number of each species per unit cell.
config_iterator config_begin()
Configuration iterator: begin.
config_iterator config_end()
Configuration iterator: end.
std::pair< iterator, bool > insert(const value_type &value)
Insert single value.
Calculate param composition of a Configuration.
BOOST_AUTO_TEST_CASE(DatumFormatters)
ConfigIO::GenericConfigFormatter< double > lattice_deformation()
ConfigIO::GenericConfigFormatter< double > rms_force()
ConfigIO::GenericConfigFormatter< double > reference_energy()
ConfigIO::GenericConfigFormatter< bool > is_primitive()
ConfigIO::GenericConfigFormatter< double > volume_relaxation()
PrimClex is the top-level data structure for a CASM project.
ConfigIO::GenericConfigFormatter< double > formation_energy()
void check_enum() override
Check "ccasm enum".
MapIteratorType base() const
ConfigIO::GenericConfigFormatter< bool > is_calculated()
ConfigIO::GenericConfigFormatter< std::string > configname()
Constructs DataFormmaterDictionary containing all Configuration DatumFormatters.
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.
ConfigIO::GenericConfigFormatter< double > basis_deformation()
ConfigIO::GenericConfigFormatter< double > reference_energy_per_species()
A 'cloneable_ptr' can be used in place of 'unique_ptr'.
ConfigIO::GenericConfigFormatter< Index > scel_size()
ConfigIO::GenericConfigFormatter< std::string > scelname()
ConfigIO::GenericConfigFormatter< Index > multiplicity()
Returns correlation values.
ConfigIO::GenericConfigFormatter< bool > is_canonical()
ConfigIO::GenericConfigFormatter< double > relaxed_energy_per_species()
virtual void check_init()
Check project initialization.
ConfigIO::GenericConfigFormatter< double > formation_energy_per_species()