fixed: BOOST_DATA_TEST_CASE was added in boost 1.67

use a loop for earlier versions
This commit is contained in:
Arne Morten Kvarving 2023-11-10 10:15:30 +01:00
parent f1fc44563a
commit e2c20a6712
2 changed files with 39 additions and 0 deletions

View File

@ -32,7 +32,11 @@
#define BOOST_TEST_MODULE Co2BrinePtFlash
#include <boost/test/unit_test.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
#include <boost/test/data/test_case.hpp>
#endif
#include <opm/material/constraintsolvers/PTFlash.hpp>
#include <opm/material/fluidsystems/Co2BrineFluidSystem.hh>
@ -55,8 +59,15 @@ using FluidState = Opm::CompositionalFluidState<Evaluation, FluidSystem>;
std::vector<std::string> test_methods {"newton", "ssi", "ssi+newton"};
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
BOOST_DATA_TEST_CASE(PtFlash, test_methods)
#else
BOOST_AUTO_TEST_CASE(PtFlash)
#endif
{
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
for (const auto& sample : test_methods) {
#endif
// Initial: the primary variables are, pressure, molar fractions of the first and second component
Evaluation p_init = Evaluation::createVariable(10e5, 0); // 10 bar
ComponentVector comp;
@ -168,10 +179,20 @@ BOOST_DATA_TEST_CASE(PtFlash, test_methods)
BOOST_CHECK_MESSAGE(Opm::MathToolbox<Evaluation>::isSame(L, ref_L, 2e-3),
"L does not match");
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
}
#endif
}
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
BOOST_DATA_TEST_CASE(PtFlashSingle, test_methods)
#else
BOOST_AUTO_TEST_CASE(PtFlashSingle)
#endif
{
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
for (const auto& sample : test_methods) {
#endif
// setting up a system that we know activates the calculations for a single-phase system
// Initial: the primary variables are, pressure, molar fractions of the first and second component
ComponentVector comp;
@ -266,4 +287,7 @@ BOOST_DATA_TEST_CASE(PtFlashSingle, test_methods)
"L does not match");
// TODO: we should also check densities, viscosities, saturations and so on
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
}
#endif
}

View File

@ -31,7 +31,11 @@
#define BOOST_TEST_MODULE PtFlash
#include <boost/test/unit_test.hpp>
#include <boost/version.hpp>
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
#include <boost/test/data/test_case.hpp>
#endif
#include <opm/material/constraintsolvers/PTFlash.hpp>
#include <opm/material/fluidsystems/ThreeComponentFluidSystem.hh>
@ -52,8 +56,15 @@ using FluidState = Opm::CompositionalFluidState<Evaluation, FluidSystem>;
std::vector<std::string> test_methods {"newton", "ssi", "ssi+newton"};
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 > 66
BOOST_DATA_TEST_CASE(PtFlash, test_methods)
#else
BOOST_AUTO_TEST_CASE(PtFlash)
#endif
{
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
for (const auto& sample : test_methods) {
#endif
// Initial: the primary variables are, pressure, molar fractions of the first and second component
Evaluation p_init = Evaluation::createVariable(10e5, 0); // 10 bar
ComponentVector comp;
@ -204,4 +215,8 @@ BOOST_DATA_TEST_CASE(PtFlash, test_methods)
BOOST_CHECK_MESSAGE(Opm::MathToolbox<Evaluation>::isSame(L, ref_L, 2e-3),
"L does not match");
#if BOOST_VERSION / 100000 == 1 && BOOST_VERSION / 100 % 1000 < 67
}
#endif
}