Add invalid size zero in WindowArray and WindowMatrix
This commit is contained in:
parent
3655aeb579
commit
ad9448c87d
@ -72,7 +72,10 @@ namespace Opm { namespace RestartIO { namespace Helpers {
|
||||
explicit WindowedArray(const NumWindows n, const WindowSize sz)
|
||||
: x_ (n.value * sz.value)
|
||||
, windowSize_(sz.value)
|
||||
{}
|
||||
{
|
||||
if (sz.value == 0)
|
||||
throw std::invalid_argument("Window array with windowsize==0 is not permitted");
|
||||
}
|
||||
|
||||
/// Retrieve number of windows allocated for this array.
|
||||
Idx numWindows() const
|
||||
@ -179,7 +182,10 @@ namespace Opm { namespace RestartIO { namespace Helpers {
|
||||
const WindowSize& sz)
|
||||
: data_ (NumWindows{ nRows.value * nCols.value }, sz)
|
||||
, numCols_(nCols.value)
|
||||
{}
|
||||
{
|
||||
if (nCols.value == 0)
|
||||
throw std::invalid_argument("Window matrix with columns==0 is not permitted");
|
||||
}
|
||||
|
||||
/// Retrieve number of columns allocated for this matrix.
|
||||
Idx numCols() const
|
||||
|
@ -30,6 +30,19 @@
|
||||
|
||||
BOOST_AUTO_TEST_SUITE(WriteOperations)
|
||||
|
||||
BOOST_AUTO_TEST_CASE(EmptyArray)
|
||||
{
|
||||
using Wa = Opm::RestartIO::Helpers::WindowedArray<int>;
|
||||
using Wm = Opm::RestartIO::Helpers::WindowedMatrix<int>;
|
||||
BOOST_CHECK_NO_THROW( Wa( Wa::NumWindows{ 0 }, Wa::WindowSize{ 1 }) );
|
||||
BOOST_CHECK_NO_THROW( Wm( Wm::NumRows{ 0 }, Wm::NumCols{ 2 }, Wm::WindowSize{ 3 } ));
|
||||
|
||||
BOOST_CHECK_THROW( Wa(Wa::NumWindows{ 5 }, Wa::WindowSize{ 0 }), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( Wm(Wm::NumRows{ 3 }, Wm::NumCols{ 0 }, Wm::WindowSize{ 4 } ), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( Wm(Wm::NumRows{ 3 }, Wm::NumCols{ 2 }, Wm::WindowSize{ 0 } ), std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
BOOST_AUTO_TEST_CASE(Array)
|
||||
{
|
||||
using Wa = Opm::RestartIO::Helpers::WindowedArray<int>;
|
||||
|
Loading…
Reference in New Issue
Block a user