Skip to content

Commit

Permalink
fix C++ tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea-Havron-NOAA committed Aug 6, 2024
1 parent 1b11de2 commit 010fe60
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
10 changes: 5 additions & 5 deletions tests/gtest/test_population_dynamics_maturity_logistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
namespace
{


TEST(LogisticMaturity, CreateObject)
{

fims_popdy::LogisticMaturity<double> maturity;
maturity.inflection_point = 20.5;
maturity.slope = 0.15;
maturity.inflection_point[0] = 20.5;
maturity.slope[0] = 0.15;
double maturity_x = 40.5;
// 1.0/(1.0+exp(-(40.5-20.5)*0.15)) = 0.9525741
double expect_maturity = 0.9525741;
Expand All @@ -19,4 +19,4 @@ namespace

}

}
}
34 changes: 20 additions & 14 deletions tests/integration/integration_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point.resize(1);
selectivity->inflection_point = a50[0].GetDouble();
selectivity->inflection_point[0] = a50[0].GetDouble();
if (print_statements) {
std::cout << "A50 " << selectivity->inflection_point[0] << "\n";
}
Expand All @@ -196,7 +196,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope.resize(1);
selectivity->slope = slope[0].GetDouble();
selectivity->slope[0] = slope[0].GetDouble();
if (print_statements) {
std::cout << "slope " << selectivity->slope[0] << "\n";
}
Expand All @@ -215,7 +215,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point_asc.resize(1);
selectivity->inflection_point_asc = a50[0].GetDouble();
selectivity->inflection_point_asc[0] = a50[0].GetDouble();
if (print_statements) {
std::cout << "A50 asc " << selectivity->inflection_point_asc[0] << "\n";
}
Expand All @@ -225,7 +225,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope_asc.resize(1);
selectivity->slope_asc = slope[0].GetDouble();
selectivity->slope_asc[0] = slope[0].GetDouble();
if (print_statements) {
std::cout << "slope asc " << selectivity->slope_asc[0] << "\n";
}
Expand All @@ -235,7 +235,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point_desc.resize(1);
selectivity->inflection_point_desc = a50[0].GetDouble();
selectivity->inflection_point_desc[0] = a50[0].GetDouble();
if (print_statements) {
std::cout << "A50 desc " << selectivity->inflection_point_desc[0] << "\n";
}
Expand All @@ -245,7 +245,7 @@ class IntegrationTest {
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope_desc.resize(1);
selectivity->slope_desc = slope[0].GetDouble();
selectivity->slope_desc[0] = slope[0].GetDouble();
if (print_statements) {
std::cout << "slope desc " << selectivity->slope_desc[0] << "\n";
}
Expand Down Expand Up @@ -333,13 +333,15 @@ class IntegrationTest {
it = fsel_o.find("A50.sel1");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point = a50[0].GetDouble();
selectivity->inflection_point.resize(1);
selectivity->inflection_point[0] = a50[0].GetDouble();
}

it = fsel_o.find("slope.sel1");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope = slope[0].GetDouble();
selectivity->slope.resize(1);
selectivity->slope[0] = slope[0].GetDouble();
}

s->selectivity = selectivity;
Expand All @@ -352,25 +354,29 @@ class IntegrationTest {
it = fsel_o.find("A50.sel1");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point_asc = a50[0].GetDouble();
selectivity->inflection_point_asc.resize(1);
selectivity->inflection_point_asc[0] = a50[0].GetDouble();
}

it = fsel_o.find("slope.sel1");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope_asc = slope[0].GetDouble();
selectivity->slope_asc.resize(1);
selectivity->slope_asc[0] = slope[0].GetDouble();
}

it = fsel_o.find("A50.sel2");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray a50 = (*it).second.GetArray();
selectivity->inflection_point_desc = a50[0].GetDouble();
selectivity->inflection_point_desc.resize(1);
selectivity->inflection_point_desc[0] = a50[0].GetDouble();
}

it = fsel_o.find("slope.sel2");
if ((*it).second.GetType() == JsonValueType::Array) {
JsonArray slope = (*it).second.GetArray();
selectivity->slope_desc = slope[0].GetDouble();
selectivity->slope_desc.resize(1);
selectivity->slope_desc[0] = slope[0].GetDouble();
}
s->selectivity = selectivity;
}
Expand Down Expand Up @@ -596,7 +602,7 @@ class IntegrationTest {
if (it != obj.end()) {
if ((*it).second.GetType() == JsonValueType::Array) {
mat->inflection_point.resize(1);
mat->inflection_point = (*it).second.GetArray()[0].GetDouble();
mat->inflection_point[0] = (*it).second.GetArray()[0].GetDouble();
if (print_statements) {
std::cout << "inflection_point.mat " << mat->inflection_point[0] << " \n";
}
Expand All @@ -613,7 +619,7 @@ class IntegrationTest {
if (it != obj.end()) {
if ((*it).second.GetType() == JsonValueType::Array) {
mat->slope.resize(1);
mat->slope = (*it).second.GetArray()[0].GetDouble();
mat->slope[0] = (*it).second.GetArray()[0].GetDouble();
if (print_statements) {
std::cout << "slope.mat " << mat->slope[0] << " \n";
}
Expand Down

0 comments on commit 010fe60

Please sign in to comment.