Skip to content

Commit

Permalink
Merge branch 'develop' into doxygen_documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
gsrohde committed Mar 5, 2024
2 parents 0ea6a2a + 0274a28 commit 95677a5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/include/run.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@


int run(int argC, char* argV[]);
std::unique_ptr<Result_xml_document> run(std::vector<std::string> command_line);
std::unique_ptr<Result_xml_document> run(std::vector<std::string> command_line_args);
std::unique_ptr<Result_xml_document> run(Option_parser op);
15 changes: 11 additions & 4 deletions app/run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,20 @@
#include "Result_xml_document.h"
#include "run.h"

std::unique_ptr<Result_xml_document> run(vector<string> command_line) {
std::vector<const char*> cstrings{};
std::unique_ptr<Result_xml_document> run(vector<string> command_line_args) {
// cstrings will take the place of argV when calling the
// Option_parser constructor. Since the constructor expects the
// command line options to start with the *second* element of the
// array (argV[0] containing the name of the command itself), we
// prepend command_line_args with a "dummy" element to represent
// this first element.
std::vector<const char*> cstrings{"dummy"};

// Convert command_line to a C-style array so that it may be
// Convert command_line_args to a C-style array so that it may be
// passed to the Option_parser constructor.
for(const auto& string : command_line)
for (const auto& string : command_line_args) {
cstrings.push_back(string.c_str());
}

// optind is a global variable used by getopt and getopt_long that
// must be reset between test invocations:
Expand Down
32 changes: 16 additions & 16 deletions tests/test_regression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ double absolute_error_bound(double expected_value) {
return std::abs(expected_value * relative_error_tolerance);
}

void compare_last_row_with_expected(const vector<string>& command_line,
void compare_last_row_with_expected(const vector<string>& command_line_args,
const vector<double>& expected_value)
{
auto result = run(command_line);
auto result = run(command_line_args);

DOMNodeList* row_list = result->get_elements_by_tag_name("row");
DOMElement* last_item = dynamic_cast< DOMElement* >(row_list->item(row_list->getLength() - 1));
Expand All @@ -47,7 +47,7 @@ void compare_last_row_with_expected(const vector<string>& command_line,


TEST(RegressionTests, TestHarmonicOscillator) {
vector<string> command_line {"", "../app/sample_input/harmonic_oscillator_system.xml"};
vector<string> command_line_args {"../app/sample_input/harmonic_oscillator_system.xml"};

// The EXPECT tests called in the compare_last_row_with_expected
// function called below make use of the fact that
Expand All @@ -62,13 +62,13 @@ TEST(RegressionTests, TestHarmonicOscillator) {
0.031853 // velocity
};

compare_last_row_with_expected(command_line, expected_value);
compare_last_row_with_expected(command_line_args, expected_value);
}


TEST(RegressionTests, TestMiscanthus2002) {
vector<string> command_line {"", "-d", "../app/sample_input/2002_weather.xml",
"../app/sample_input/biocro-system.miscanthus.xml"};
vector<string> command_line_args {"-d", "../app/sample_input/2002_weather.xml",
"../app/sample_input/biocro-system.miscanthus.xml"};

// The EXPECT tests called in the compare_last_row_with_expected
// function called below make use of the fact that
Expand Down Expand Up @@ -140,13 +140,13 @@ TEST(RegressionTests, TestMiscanthus2002) {
2002 // year
};

compare_last_row_with_expected(command_line, expected_value);
compare_last_row_with_expected(command_line_args, expected_value);
}


TEST(RegressionTests, TestMiscanthus2005) {
vector<string> command_line {"", "-d", "../app/sample_input/2005_weather.xml",
"../app/sample_input/biocro-system.miscanthus.xml"};
vector<string> command_line_args {"-d", "../app/sample_input/2005_weather.xml",
"../app/sample_input/biocro-system.miscanthus.xml"};

// The EXPECT tests called in the compare_last_row_with_expected
// function called below make use of the fact that
Expand Down Expand Up @@ -218,13 +218,13 @@ TEST(RegressionTests, TestMiscanthus2005) {
2005 // year
};

compare_last_row_with_expected(command_line, expected_value);
compare_last_row_with_expected(command_line_args, expected_value);
}


TEST(RegressionTests, TestWillow2005) {
vector<string> command_line {"", "-d", "../app/sample_input/2005_weather.xml",
"../app/sample_input/biocro-system.willow.xml"};
vector<string> command_line_args {"-d", "../app/sample_input/2005_weather.xml",
"../app/sample_input/biocro-system.willow.xml"};

// The EXPECT tests called in the compare_last_row_with_expected
// function called below make use of the fact that
Expand Down Expand Up @@ -296,13 +296,13 @@ TEST(RegressionTests, TestWillow2005) {
2005 // year
};

compare_last_row_with_expected(command_line, expected_value);
compare_last_row_with_expected(command_line_args, expected_value);
}


TEST(RegressionTests, TestWillow2002) {
vector<string> command_line {"", "-d", "../app/sample_input/2002_weather.xml",
"../app/sample_input/biocro-system.willow.xml"};
vector<string> command_line_args {"-d", "../app/sample_input/2002_weather.xml",
"../app/sample_input/biocro-system.willow.xml"};

// The EXPECT tests called in the compare_last_row_with_expected
// function called below make use of the fact that
Expand Down Expand Up @@ -374,5 +374,5 @@ TEST(RegressionTests, TestWillow2002) {
2002 // year
};

compare_last_row_with_expected(command_line, expected_value);
compare_last_row_with_expected(command_line_args, expected_value);
}

0 comments on commit 95677a5

Please sign in to comment.