From 010fe60ab11f7880324c545c6718bf621e2df0df Mon Sep 17 00:00:00 2001 From: Andrea-Havron-NOAA Date: Tue, 6 Aug 2024 12:44:40 -0700 Subject: [PATCH] fix C++ tests --- ..._population_dynamics_maturity_logistic.cpp | 10 +++--- tests/integration/integration_class.hpp | 34 +++++++++++-------- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/tests/gtest/test_population_dynamics_maturity_logistic.cpp b/tests/gtest/test_population_dynamics_maturity_logistic.cpp index 3997aa0fa..78c17609b 100644 --- a/tests/gtest/test_population_dynamics_maturity_logistic.cpp +++ b/tests/gtest/test_population_dynamics_maturity_logistic.cpp @@ -4,13 +4,13 @@ namespace { - + TEST(LogisticMaturity, CreateObject) { - + fims_popdy::LogisticMaturity 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; @@ -19,4 +19,4 @@ namespace } -} \ No newline at end of file +} diff --git a/tests/integration/integration_class.hpp b/tests/integration/integration_class.hpp index 014fe4981..f3afb83ef 100644 --- a/tests/integration/integration_class.hpp +++ b/tests/integration/integration_class.hpp @@ -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"; } @@ -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"; } @@ -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"; } @@ -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"; } @@ -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"; } @@ -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"; } @@ -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; @@ -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; } @@ -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"; } @@ -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"; }