Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instead of macros, use fixtures for XPRESS tests #119

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

flomnes
Copy link
Collaborator

@flomnes flomnes commented Nov 23, 2023

Only difficulty : UNITTEST_INIT_MIP() is used in loops, e.g

for (const auto& [paramString, control, paramValue] : params) {
  UNITTEST_INIT_MIP();
  std::string xpressParamString = paramString + " " + paramValue;
  solver.SetSolverSpecificParametersAsString(xpressParamString);
  EXPECT_EQ(paramValue, getter.getStringControl(control));
}

This has been dealt with by replacing the macro with it's content in each of the 3 loops.

for (const auto& [paramString, control, paramValue] : params) {
   MPSolver solver("XPRESS_MIP", MPSolver::XPRESS_MIXED_INTEGER_PROGRAMMING);
   XPRSGetter getter(&solver);
   // ...
}

@flomnes flomnes marked this pull request as draft November 23, 2023 15:21
@pet-mit
Copy link
Collaborator

pet-mit commented Nov 23, 2023

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

@flomnes
Copy link
Collaborator Author

flomnes commented Nov 23, 2023

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

According to this source, constructor/destructor should be used whenever possible.

@pet-mit
Copy link
Collaborator

pet-mit commented Nov 23, 2023

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

According to this source, constructor/destructor should be used whenever possible.

then maybe, if possible, add a protected reset() method that resets the MIP ?

@flomnes
Copy link
Collaborator Author

flomnes commented Nov 24, 2023

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

According to this source, constructor/destructor should be used whenever possible.

then maybe, if possible, add a protected reset() method that resets the MIP ?

For every test, an XpressFixtureMIP is created into the function scope, then destroyed at the end. There is no sharing of a single object among tests.

@pet-mit
Copy link
Collaborator

pet-mit commented Dec 1, 2023

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

According to this source, constructor/destructor should be used whenever possible.

then maybe, if possible, add a protected reset() method that resets the MIP ?

For every test, an XpressFixtureMIP is created into the function scope, then destroyed at the end. There is no sharing of a single object among tests.

I meant, a reset() method would maybe help to solve the loop issue

@flomnes flomnes force-pushed the fix/use-fixtures-for-xpress-tests branch from a50778b to a7bf7ad Compare January 9, 2024 16:04
@flomnes
Copy link
Collaborator Author

flomnes commented Jan 9, 2024

Maybe you can use SetUp() instead of constructor in fixture, that way you can call it multiple time (see google doc)

According to this source, constructor/destructor should be used whenever possible.

then maybe, if possible, add a protected reset() method that resets the MIP ?

For every test, an XpressFixtureMIP is created into the function scope, then destroyed at the end. There is no sharing of a single object among tests.

I meant, a reset() method would maybe help to solve the loop issue

@pet-mit Since this was only used 3 times (3 for loops), I just copy-pasted the 2 lines of codes each time. I hope the elimination of macros will make it up for this code duplication. Alternatively, I can keep the UNITTEST_INIT_MIP() macro, and use it only in these 3 for loops, and isolate it with #define #undef.

@flomnes flomnes marked this pull request as ready for review January 9, 2024 16:10
@flomnes flomnes force-pushed the fix/use-fixtures-for-xpress-tests branch from a7bf7ad to 9f490be Compare January 9, 2024 16:47
@flomnes flomnes changed the base branch from main to release/9.8-rte1.0 January 9, 2024 16:47
@sgatto sgatto changed the base branch from release/9.8-rte1.0 to main January 16, 2024 10:22
@sgatto sgatto merged commit bf80b7b into main Jan 16, 2024
25 checks passed
@flomnes flomnes deleted the fix/use-fixtures-for-xpress-tests branch March 22, 2024 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants