Skip to content
Snippets Groups Projects
Commit 75666b5e authored by Ian Bell's avatar Ian Bell
Browse files

Fix C interface test

parent ea3317e4
No related branches found
No related tags found
No related merge requests found
......@@ -7,7 +7,7 @@
#include <variant>
#include <atomic>
#include "teqpcpp.hpp"
#include "teqp/cpp/teqpcpp.hpp"
#include "teqp/exceptions.hpp"
// Define empty macros so that no exporting happens
......@@ -41,7 +41,7 @@ std::string get_uid(int N) {
return std::string(N - s.size(), '0') + s;
}
std::unordered_map<std::string, std::unique_ptr<teqp::cppinterface::AbstractModel>> library;
std::unordered_map<std::string, std::shared_ptr<teqp::cppinterface::AbstractModel>> library;
void exception_handler(int& errcode, char* message_buffer, const int buffer_length)
{
......@@ -221,19 +221,24 @@ TEST_CASE("Use of C interface","[teqpc]") {
};
BENCHMARK("PCSAFT") {
nlohmann::json jmodel = nlohmann::json::array();
nlohmann::json jcoeffs = nlohmann::json::array();
std::valarray<double> molefrac = { 0.4, 0.6 };
jmodel.push_back({ {"name", "Methane"}, { "m", 1.0 }, { "sigma_Angstrom", 3.7039},{"epsilon_over_k", 150.03}, {"BibTeXKey", "Gross-IECR-2001"} });
jmodel.push_back({ {"name", "Ethane"}, { "m", 1.6069 }, { "sigma_Angstrom", 3.5206},{"epsilon_over_k", 191.42}, {"BibTeXKey", "Gross-IECR-2001"} });
jcoeffs.push_back({ {"name", "Methane"}, { "m", 1.0 }, { "sigma_Angstrom", 3.7039},{"epsilon_over_k", 150.03}, {"BibTeXKey", "Gross-IECR-2001"} });
jcoeffs.push_back({ {"name", "Ethane"}, { "m", 1.6069 }, { "sigma_Angstrom", 3.5206},{"epsilon_over_k", 191.42}, {"BibTeXKey", "Gross-IECR-2001"} });
nlohmann::json model = {
{"coeffs", jcoeffs}
};
nlohmann::json j = {
{"kind", "PCSAFT"},
{"model", jmodel}
{"model", model}
};
std::string js = j.dump(2);
int e1 = build_model(j.dump(2).c_str(), uuid, errmsg, errmsg_length);
std::string js = j.dump(1);
int e1 = build_model(js.c_str(), uuid, errmsg, errmsg_length);
CAPTURE(errmsg);
CAPTURE(js);
REQUIRE(e1 == 0);
int e2 = get_Arxy(uuid, 0, 1, 300, 3.0e-6, &(molefrac[0]), molefrac.size(), &val, errmsg, errmsg_length);
int e3 = free_model(uuid, errmsg, errmsg_length);
REQUIRE(e1 == 0);
REQUIRE(e2 == 0);
REQUIRE(e3 == 0);
return val;
......@@ -292,4 +297,4 @@ TEST_CASE("Use of C interface","[teqpc]") {
#else
int main() {
}
#endif
\ No newline at end of file
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment